aboutsummaryrefslogtreecommitdiffstats
path: root/railties/bin
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-14 08:23:50 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-14 08:23:50 +0000
commit624d5bb176de5212bea43a1c57a95f48676c6e9f (patch)
tree9bba432db896b085abe9e233dc037312cea197cf /railties/bin
parent75b8ac80d988c39e48966d6b60f0d1d46c0d75a6 (diff)
downloadrails-624d5bb176de5212bea43a1c57a95f48676c6e9f.tar.gz
rails-624d5bb176de5212bea43a1c57a95f48676c6e9f.tar.bz2
rails-624d5bb176de5212bea43a1c57a95f48676c6e9f.zip
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
Diffstat (limited to 'railties/bin')
-rw-r--r--railties/bin/benchmarker16
-rw-r--r--railties/bin/console_sandbox (renamed from railties/bin/console_sandbox.rb)0
-rw-r--r--railties/bin/profiler14
3 files changed, 30 insertions, 0 deletions
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
diff --git a/railties/bin/console_sandbox.rb b/railties/bin/console_sandbox
index 80f3dbc223..80f3dbc223 100644
--- a/railties/bin/console_sandbox.rb
+++ b/railties/bin/console_sandbox
diff --git a/railties/bin/profiler b/railties/bin/profiler
new file mode 100644
index 0000000000..aca84055c2
--- /dev/null
+++ b/railties/bin/profiler
@@ -0,0 +1,14 @@
+#!/usr/local/bin/ruby
+
+if ARGV.empty?
+ puts "Usage: profiler 'Person.expensive_method(10)' [times]"
+ exit
+end
+
+require File.dirname(__FILE__) + '/../config/environment'
+require "profiler"
+
+Profiler__::start_profile
+(ARGV[1] || 1).to_i.times { eval(ARGV.first) }
+Profiler__::stop_profile
+Profiler__::print_profile($stdout) \ No newline at end of file