diff options
author | José Valim <jose.valim@gmail.com> | 2010-04-29 08:39:44 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-04-29 08:39:52 +0200 |
commit | 1b816d502444ce2b3153d8c689d0057f1c257eee (patch) | |
tree | 4fb975de78c82295568b64bde76132084c8089ac /railties/lib/rails/commands/benchmarker.rb | |
parent | e33d304975f5b20b0ba819ab644a2a8f80ff3743 (diff) | |
download | rails-1b816d502444ce2b3153d8c689d0057f1c257eee.tar.gz rails-1b816d502444ce2b3153d8c689d0057f1c257eee.tar.bz2 rails-1b816d502444ce2b3153d8c689d0057f1c257eee.zip |
The rake task :environment now loads config/environment.rb instead of initializing the application on its own. This fixes [#4492 state:resolved] and also avoids the application being initialized twice in some rake tasks.
Diffstat (limited to 'railties/lib/rails/commands/benchmarker.rb')
-rw-r--r-- | railties/lib/rails/commands/benchmarker.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/railties/lib/rails/commands/benchmarker.rb b/railties/lib/rails/commands/benchmarker.rb new file mode 100644 index 0000000000..0432261802 --- /dev/null +++ b/railties/lib/rails/commands/benchmarker.rb @@ -0,0 +1,23 @@ +if [nil, "-h", "--help"].include?(ARGV.first) + puts "Usage: rails benchmarker [times] 'Person.expensive_way' 'Person.another_expensive_way' ..." + exit 1 +end + +begin + N = Integer(ARGV.first) + ARGV.shift +rescue ArgumentError + N = 1 +end + +require 'benchmark' +include Benchmark + +# Don't include compilation in the benchmark +ARGV.each { |expression| eval(expression) } + +bm(6) do |x| + ARGV.each_with_index do |expression, idx| + x.report("##{idx + 1}") { N.times { eval(expression) } } + end +end |