Sha256: 99ae674a654a1e2fce068e0fe501803d2a4ef2e65faf8494aa1e55f487ed2d63
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
#!/usr/bin/env ruby require 'optparse' require 'stackprof' options = { :format => :text, :sort => false, :limit => 30 } parser = OptionParser.new(ARGV) do |o| o.banner = "Usage: stackprof [file.dump]+ [--text|--method=NAME|--callgrind|--graphviz]" o.on('--text', 'Text summary per method (default)'){ options[:format] = :text } o.on('--files', 'List of files'){ |f| options[:format] = :files } o.on('--limit=[num]', Integer, 'Limit --text or --files output to N lines'){ |n| options[:limit] = n } o.on('--sort-total', "Sort --text or --files output on total samples\n\n"){ options[:sort] = true } o.on('--method=[grep]', 'Zoom into specified method'){ |f| options[:format] = :method; options[:filter] = f } o.on('--file=[grep]', 'Show annotated code for specified file'){ |f| options[:format] = :file; options[:filter] = f } o.on('--callgrind', 'Callgrind output (use with kcachegrind, gprof2dot)'){ options[:format] = :callgrind } o.on('--graphviz', "Graphviz output (use with dot)\n\n"){ options[:format] = :graphviz } o.on('--debug', 'Pretty print raw profile data'){ options[:format] = :debug } end parser.parse! parser.abort(parser.help) if ARGV.empty? reports = [] while ARGV.size > 0 reports << StackProf::Report.new(Marshal.load(IO.binread(ARGV.pop))) end report = reports.inject(:+) case options[:format] when :text report.print_text(options[:sort], options[:limit]) when :debug report.print_debug when :callgrind report.print_callgrind when :graphviz report.print_graphviz when :method report.print_method(options[:filter]) when :file report.print_file(options[:filter]) when :files report.print_files(options[:sort], options[:limit]) else raise ArgumentError, "unknown format: #{options[:format]}" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stackprof-0.2.2 | bin/stackprof |