blob: d606a76abf72f5f13dd41f90007b6543a9e93360 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/usr/local/bin/ruby
if ARGV.empty?
$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'
# Default to a single execution.
N = (ARGV[1] || 1).to_i
# 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
|