From 624d5bb176de5212bea43a1c57a95f48676c6e9f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 14 Apr 2005 08:23:50 +0000 Subject: Added script/benchmarker to easily benchmark one or more statement a number of times from within the environment. Added script/profiler to easily profile a single statement from within the environment git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1166 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/bin/benchmarker | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 railties/bin/benchmarker (limited to 'railties/bin/benchmarker') diff --git a/railties/bin/benchmarker b/railties/bin/benchmarker new file mode 100644 index 0000000000..a5814d98a6 --- /dev/null +++ b/railties/bin/benchmarker @@ -0,0 +1,16 @@ +#!/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 + +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