aboutsummaryrefslogtreecommitdiffstats
path: root/railties/bin/profiler
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-30 15:37:45 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-30 15:37:45 +0000
commit54f2d1d944bb7577ef33ab086191992210f4788c (patch)
tree2362ded764df45f2d931cfe4d5f665f580067894 /railties/bin/profiler
parente6f3e5d90017f3f642dd2f4205679cc861a8a2ab (diff)
downloadrails-54f2d1d944bb7577ef33ab086191992210f4788c.tar.gz
rails-54f2d1d944bb7577ef33ab086191992210f4788c.tar.bz2
rails-54f2d1d944bb7577ef33ab086191992210f4788c.zip
Added console --profile for profiling an IRB session #1154 [bitsweat]. Changed console_sandbox into console --sandbox #1154 [bitsweat]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1261 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/bin/profiler')
-rw-r--r--railties/bin/profiler27
1 files changed, 19 insertions, 8 deletions
diff --git a/railties/bin/profiler b/railties/bin/profiler
index f0f14a2b99..d606a76abf 100644
--- a/railties/bin/profiler
+++ b/railties/bin/profiler
@@ -1,17 +1,28 @@
#!/usr/local/bin/ruby
if ARGV.empty?
- puts "Usage: profiler 'Person.expensive_method(10)' [times]"
+ $stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times]"
exit
end
+# Keep the expensive require out of the profile.
+puts 'Loading Rails...'
require File.dirname(__FILE__) + '/../config/environment'
-require "profiler"
-# Don't include compilation in the profile
-eval(ARGV.first)
+# Default to a single execution.
+N = (ARGV[1] || 1).to_i
-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
+# Define a method to profile.
+eval <<end_eval
+def profile_me
+ for i in 1..#{N}
+ #{ARGV[0]}
+ end
+end
+end_eval
+
+# Require the profiler at_exit wrapper from railties/lib.
+require 'console_profile'
+
+# Blast off!
+profile_me