diff --git a/actionpack/lib/action_controller/request_profiler.rb b/actionpack/lib/action_controller/request_profiler.rb index 6a023b652eeb8a3a1781179025d3643bfcb804ae..8a18d194bdd507c497ea1b4ac81ba909328851c8 100755 --- a/actionpack/lib/action_controller/request_profiler.rb +++ b/actionpack/lib/action_controller/request_profiler.rb @@ -119,6 +119,7 @@ def parse_options(args) opt.on('-n', '--times [100]', 'How many requests to process. Defaults to 100.') { |v| options[:n] = v.to_i if v } opt.on('-b', '--benchmark', 'Benchmark instead of profiling') { |v| options[:benchmark] = v } + opt.on('-m', '--measure [mode]', 'Which ruby-prof measure mode to use: process_time, wall_time, cpu_time, allocations, or memory. Defaults to process_time.') { |v| options[:measure] = v } opt.on('--open [CMD]', 'Command to open profile results. Defaults to "open %s &"') { |v| options[:open] = v } opt.on('-h', '--help', 'Show this help') { puts opt; exit } @@ -136,7 +137,9 @@ def parse_options(args) def load_ruby_prof begin require 'ruby-prof' - #RubyProf.measure_mode = RubyProf::ALLOCATED_OBJECTS + if mode = options[:measure] + RubyProf.measure_mode = RubyProf.const_get(mode.upcase) + end rescue LoadError abort '`gem install ruby-prof` to use the profiler' end