Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8477

Show
Ignore:
Timestamp:
12/22/07 04:49:56 (9 months ago)
Author:
bitsweat
Message:

Fold reset! into the run method directly. Make -n options compatible with Ruby 1.9 whose option parser seems to call the block with nil value even when the option is omitted.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/request_profiler.rb

    r8475 r8477  
    2121        @quiet = true 
    2222        print '  ' 
     23 
    2324        result = Benchmark.realtime do 
    2425          n.times do |i| 
    2526            run 
    26             reset! 
    2727            print_progress(i) 
    2828          end 
    2929        end 
     30 
    3031        puts 
    3132        result 
     
    4142        def define_run_method(script_path) 
    4243          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 
    4446        end 
    4547 
     
    9597 
    9698    def warmup(sandbox) 
    97       Benchmark.realtime do 
    98         sandbox.run 
    99         sandbox.reset! 
    100       end 
     99      Benchmark.realtime { sandbox.run } 
    101100    end 
    102101 
     
    110109        opt.banner = "USAGE: #{$0} [options] [session script path]" 
    111110 
    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
    113112        opt.on('-b', '--benchmark', 'Benchmark instead of profiling') { |v| options[:benchmark] = v } 
    114113        opt.on('--open [CMD]', 'Command to open profile results. Defaults to "open %s &"') { |v| options[:open] = v }