Changeset 8477
- Timestamp:
- 12/22/07 04:49:56 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/request_profiler.rb
r8475 r8477 21 21 @quiet = true 22 22 print ' ' 23 23 24 result = Benchmark.realtime do 24 25 n.times do |i| 25 26 run 26 reset!27 27 print_progress(i) 28 28 end 29 29 end 30 30 31 puts 31 32 result … … 41 42 def define_run_method(script_path) 42 43 script = File.read(script_path) 43 instance_eval "def run; #{script}; end", script_path, 1 44 source = "def run\n#{script}\nreset!\nend" 45 instance_eval source, script_path, 1 44 46 end 45 47 … … 95 97 96 98 def warmup(sandbox) 97 Benchmark.realtime do 98 sandbox.run 99 sandbox.reset! 100 end 99 Benchmark.realtime { sandbox.run } 101 100 end 102 101 … … 110 109 opt.banner = "USAGE: #{$0} [options] [session script path]" 111 110 112 opt.on('-n', '--times [ 0000]', 'How many requests to process. Defaults to 100.') { |v| options[:n] = v.to_i}111 opt.on('-n', '--times [100]', 'How many requests to process. Defaults to 100.') { |v| options[:n] = v.to_i if v } 113 112 opt.on('-b', '--benchmark', 'Benchmark instead of profiling') { |v| options[:benchmark] = v } 114 113 opt.on('--open [CMD]', 'Command to open profile results. Defaults to "open %s &"') { |v| options[:open] = v }