bin/ruby-prof in ruby-prof-0.18.0 vs bin/ruby-prof in ruby-prof-1.0.0

- old
+ new

@@ -1,30 +1,78 @@ #! /usr/bin/env ruby -# == Synopsis -# -# Profiles a Ruby program. -# -# == Usage -# -# ruby_prof [options] <script.rb> [--] [script-options]" -# -# Various options: -# run "$ ruby-prof --help" to see them -# -# See also the readme "reports" section for the various outputs - # First require ruby-prof require 'rubygems' require 'ruby-prof' # Now setup option parser require 'ostruct' require 'optparse' module RubyProf + # == Synopsis + # + # Profiles a Ruby program. + # + # == Usage + # + # ruby_prof [options] <script.rb> [--] [script-options] + # + # Options: + # -p, --printer=printer Select a printer: + # flat - Prints a flat profile as text (default). + # 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 + # multi - Creates several reports in output directory + # + # -m, --min_percent=min_percent The minimum percent a method must take before + # being included in output reports. This option is not supported for call tree reports. + # + # -f, --file=path Output results to a file instead of standard out. + # + # --mode=measure_mode Select what ruby-prof should measure: + # wall - Wall time (default) + # process - Process time + # allocations - Object allocations + # memory - Allocated memory + # + # -s, --sort=sort_mode Select how ruby-prof results should be sorted: + # total - Total time + # self - Self time + # wait - Wait time + # child - Child time + # + # --replace-progname Replace $0 when loading the .rb files. + # + # --specialized-instruction Turn on specified instruction. + # + # -v Show version, set $VERBOSE to true, profile script if option given + # + # -d Set $DEBUG to true + # + # -R, --require-noprof lib Require a specific library (not profiled) + # + # -E, --eval-noprof code Execute the ruby statements (not profiled) + # + # -x, --exclude regexp Exclude methods by regexp (see method elimination) + # + # -X, --exclude-file file Exclude methods by regexp listed in file (see method elimination) + # + # --exclude-common-cycles Make common iterators like Integer#times appear inlined + # + # --exclude-common-callbacks Make common callbacks invocations like Integer#times appear inlined so you can see call origins in graph + # + # -h, --help Show help message + # + # --version Show version + # + # class Cmd + # :enddoc: attr_accessor :options def initialize setup_options parse_args @@ -54,25 +102,21 @@ opts.separator "Options:" opts.on('-p printer', '--printer=printer', [:flat, :flat_with_line_numbers, :graph, :graph_html, :call_tree, :call_stack, :dot, :multi], '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_stack - prints a HTML visualization of the call tree', ' dot - Prints a graph profile as a dot file', ' multi - Creates several reports in output directory' ) do |printer| - case printer when :flat options.printer = RubyProf::FlatPrinter - when :flat_with_line_numbers - options.printer = RubyProf::FlatPrinterWithLineNumbers when :graph options.printer = RubyProf::GraphPrinter when :graph_html options.printer = RubyProf::GraphHtmlPrinter when :call_tree @@ -87,46 +131,37 @@ end opts.on('-m min_percent', '--min_percent=min_percent', Float, 'The minimum percent a method must take before ', ' being included in output reports.', - ' this option is not supported for call tree.') do |min_percent| + ' This option is not supported for call tree.') do |min_percent| options.min_percent = min_percent 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], + [:process, :wall, :allocations, :memory], 'Select what ruby-prof should measure:', ' wall - Wall time (default).', ' process - Process time.', - ' cpu - CPU time (Pentium and PowerPCs only).', ' allocations - Object allocations (requires patched Ruby interpreter).', - ' memory - Allocated memory in KB (requires patched Ruby interpreter).', - ' gc_runs - Number of garbage collections (requires patched Ruby interpreter).', - ' gc_time - Time spent in garbage collection (requires patched Ruby interpreter).') do |measure_mode| + ' memory - Allocated memory in KB (requires patched Ruby interpreter).') do |measure_mode| case measure_mode when :wall options.measure_mode = RubyProf::WALL_TIME when :process options.measure_mode = RubyProf::PROCESS_TIME - when :cpu - options.measure_mode = RubyProf::CPU_TIME when :allocations options.measure_mode = RubyProf::ALLOCATIONS when :memory options.measure_mode = RubyProf::MEMORY - when :gc_runs - options.measure_mode = RubyProf::GC_RUNS - when :gc_time - options.measure_mode = RubyProf::GC_TIME end end opts.on('-s sort_mode', '--sort=sort_mode', [:total, :self, :wait, :child], 'Select how ruby-prof results should be sorted:', @@ -182,10 +217,10 @@ opts.on('-E code', '--eval-noprof code', 'execute the ruby statements (not profiled)') do |code| options.pre_execs << code end - opts.on('-x regexp', '--exclude regexp', 'exclude methods by regexp (see method elimination)') do|meth| + opts.on('-x regexp', '--exclude regexp', 'exclude methods by regexp (see method elimination)') do |meth| options.eliminate_methods ||= [] options.eliminate_methods << Regexp.new(meth) end opts.on('-X file', '--exclude-file file', 'exclude methods by regexp listed in file (see method elimination)') do|file|