aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-10-14 14:46:27 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-10-14 14:46:27 +0000
commit86455d31f2ee88c9f476627ee6ebf1b242d962bb (patch)
tree4e3aea001de9813c38fbac6c832ab1105005f8db /railties
parentd8738be0b97787b3f9ab5958d0c8d49175417d1a (diff)
downloadrails-86455d31f2ee88c9f476627ee6ebf1b242d962bb.tar.gz
rails-86455d31f2ee88c9f476627ee6ebf1b242d962bb.tar.bz2
rails-86455d31f2ee88c9f476627ee6ebf1b242d962bb.zip
Sanitize benchmarker. [times] argument is optional, defaults to 1.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2583 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/commands/perform/benchmarker.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/railties/lib/commands/perform/benchmarker.rb b/railties/lib/commands/perform/benchmarker.rb
index 296192f53c..b12cf57215 100644
--- a/railties/lib/commands/perform/benchmarker.rb
+++ b/railties/lib/commands/perform/benchmarker.rb
@@ -2,7 +2,14 @@
if ARGV.empty?
puts "Usage: ./script/perform benchmarker [times] 'Person.expensive_way' 'Person.another_expensive_way' ..."
- exit
+ exit 1
+end
+
+begin
+ N = Integer(ARGV.first)
+ ARGV.shift
+rescue ArgumentError
+ N = 1
end
require RAILS_ROOT + '/config/environment'
@@ -10,10 +17,10 @@ require 'benchmark'
include Benchmark
# Don't include compilation in the benchmark
-ARGV[1..-1].each { |expression| eval(expression) }
+ARGV.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) } }
+ ARGV.each_with_index do |expression, idx|
+ x.report("##{idx + 1}") { N.times { eval(expression) } }
end
-end \ No newline at end of file
+end