diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-14 02:29:56 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-14 02:29:56 +0000 |
commit | cb24c0f14158b392e86b5948c6091398aab0a968 (patch) | |
tree | f6098831fad3a44f2e5b679b8dc950b1a13e72e3 /railties/lib/commands/perform/benchmarker.rb | |
parent | 2bb72134b57e92109809ed80d725001d5db0a8cf (diff) | |
download | rails-cb24c0f14158b392e86b5948c6091398aab0a968.tar.gz rails-cb24c0f14158b392e86b5948c6091398aab0a968.tar.bz2 rails-cb24c0f14158b392e86b5948c6091398aab0a968.zip |
Performers go .rb
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2575 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/commands/perform/benchmarker.rb')
-rw-r--r-- | railties/lib/commands/perform/benchmarker.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/railties/lib/commands/perform/benchmarker.rb b/railties/lib/commands/perform/benchmarker.rb new file mode 100644 index 0000000000..b07ddcfcb2 --- /dev/null +++ b/railties/lib/commands/perform/benchmarker.rb @@ -0,0 +1,19 @@ +#!/usr/local/bin/ruby + +if ARGV.empty? + puts "Usage: benchmarker times 'Person.expensive_way' 'Person.another_expensive_way' ..." + exit +end + +require File.dirname(__FILE__) + '/../config/environment' +require 'benchmark' +include Benchmark + +# Don't include compilation in the benchmark +ARGV[1..-1].each { |expression| eval(expression) } + +bm(6) do |x| + ARGV[1..-1].each_with_index do |expression, idx| + x.report("##{idx + 1}") { ARGV[0].to_i.times { eval(expression) } } + end +end
\ No newline at end of file |