From cb24c0f14158b392e86b5948c6091398aab0a968 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 14 Oct 2005 02:29:56 +0000 Subject: Performers go .rb git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2575 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/lib/commands/perform/benchmarker.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 railties/lib/commands/perform/benchmarker.rb (limited to 'railties/lib/commands/perform/benchmarker.rb') 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 -- cgit v1.2.3