bin/ruby-prof in ruby-prof-0.8.2 vs bin/ruby-prof in ruby-prof-0.9.0
- old
+ new
@@ -13,10 +13,12 @@
# flat - Prints a flat profile as text (default).
# flat_with_line_numbers - Above, with line numbers
# graph - Prints a graph profile as text.
# graph_html - Prints a graph profile as html.
# call_tree - format for KCacheGrind
+# call_stack - prints a HTML visualization of the call tree
+# dot - Prints a graph profile as a dot file
# -f, --file=path Output results to a file instead of standard out.
# -m, --min_percent=min_percent The minimum percent a method must take before ',
# being included in output reports. Should be an
# integer between 1 and 100. 0 means all methods are printed.
# --mode=measure_mode Select a measurement mode:
@@ -61,17 +63,19 @@
opts.separator ""
opts.separator "Options:"
- opts.on('-p printer', '--printer=printer', [:flat, :flat_with_line_numbers, :graph, :graph_html, :call_tree],
+ opts.on('-p printer', '--printer=printer', [:flat, :flat_with_line_numbers, :graph, :graph_html, :call_tree, :call_stack, :dot],
'Select a printer:',
' flat - Prints a flat profile as text (default).',
' flat_with_line_numbers - same as flat, with line numbers.',
' graph - Prints a graph profile as text.',
' graph_html - Prints a graph profile as html.',
- ' call_tree - format for KCacheGrind'
+ ' call_tree - format for KCacheGrind',
+ ' call_stack - prints a HTML visualization of the call tree',
+ ' dot - Prints a graph profile as a dot file'
) do |printer|
case printer
when :flat
@@ -82,10 +86,14 @@
options.printer = RubyProf::GraphPrinter
when :graph_html
options.printer = RubyProf::GraphHtmlPrinter
when :call_tree
options.printer = RubyProf::CallTreePrinter
+ when :call_stack
+ options.printer = RubyProf::CallStackPrinter
+ when :dot
+ options.printer = RubyProf::DotPrinter
end
end
opts.on('-m min_percent', '--min_percent=min_percent', Float,
'The minimum percent a method must take before ',
@@ -95,10 +103,11 @@
end
opts.on('-f path', '--file=path',
'Output results to a file instead of standard out.') do |file|
options.file = file
+ options.old_wd = Dir.pwd
end
opts.on('--mode=measure_mode',
[:process, :wall, :cpu, :allocations, :memory, :gc_runs, :gc_time],
'Select what ruby-prof should measure:',
@@ -189,11 +198,14 @@
# Create a printer
printer = options.printer.new(result)
# Get output
if options.file
- File.open(options.file, 'w') do |file|
- printer.print(file, {:min_percent => options.min_percent})
+ # write it relative to the dir they *started* in, as it's a bit surprising to write it in the dir they end up in.
+ Dir.chdir(options.old_wd) do
+ File.open(options.file, 'w') do |file|
+ printer.print(file, {:min_percent => options.min_percent})
+ end
end
else
# Print out results
printer.print(STDOUT, {:min_percent => options.min_percent})
end
\ No newline at end of file