Merged tracks-mu-import branch changes r113:130 into the trunk

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@131 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
nic 2005-08-08 01:54:05 +00:00
parent 2d2f9fcca8
commit 91641500a7
75 changed files with 4054 additions and 1375 deletions

View file

@ -1,17 +1,34 @@
#!/usr/bin/ruby
#!/usr/bin/ruby1.8
if ARGV.empty?
puts "Usage: profiler 'Person.expensive_method(10)' [times]"
exit
$stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times]"
exit(1)
end
# Keep the expensive require out of the profile.
$stderr.puts 'Loading Rails...'
require File.dirname(__FILE__) + '/../config/environment'
require "profiler"
# Don't include compilation in the profile
eval(ARGV.first)
# Define a method to profile.
if ARGV[1] and ARGV[1].to_i > 1
eval "def profile_me() #{ARGV[1]}.times { #{ARGV[0]} } end"
else
eval "def profile_me() #{ARGV[0]} end"
end
Profiler__::start_profile
(ARGV[1] || 1).to_i.times { eval(ARGV.first) }
Profiler__::stop_profile
Profiler__::print_profile($stdout)
# Use the ruby-prof extension if available. Fall back to stdlib profiler.
begin
require 'prof'
$stderr.puts 'Using the ruby-prof extension.'
Prof.clock_mode = Prof::GETTIMEOFDAY
Prof.start
profile_me
results = Prof.stop
require 'rubyprof_ext'
Prof.print_profile(results, $stderr)
rescue LoadError
$stderr.puts 'Using the standard Ruby profiler.'
Profiler__.start_profile
profile_me
Profiler__.stop_profile
Profiler__.print_profile($stderr)
end