bin/stackprof in stackprof-0.2.23 vs bin/stackprof in stackprof-0.2.24
- old
+ new
@@ -1,16 +1,18 @@
#!/usr/bin/env ruby
require 'optparse'
require 'stackprof'
+banner = <<-END
+Usage: stackprof run [--mode=MODE|--out=FILE|--interval=INTERVAL|--format=FORMAT] -- COMMAND
+Usage: stackprof [file.dump]+ [--text|--method=NAME|--callgrind|--graphviz]
+END
+
if ARGV.first == "run"
ARGV.shift
env = {}
- parser = OptionParser.new(ARGV) do |o|
- o.banner = "Usage: stackprof run [--mode=MODE|--out=FILE|--interval=INTERVAL|--format=FORMAT] -- COMMAND"
- o.banner = "Usage: stackprof [file.dump]+ [--text|--method=NAME|--callgrind|--graphviz]"
-
+ parser = OptionParser.new(banner) do |o|
o.on('--mode [MODE]', String, 'Mode of sampling: cpu, wall, object, default to wall') do |mode|
env["STACKPROF_MODE"] = mode
end
o.on('--out [FILENAME]', String, 'The target file, which will be overwritten. Defaults to a random temporary file') do |out|
@@ -35,13 +37,10 @@
env['RUBYOPT'] = "-I #{stackprof_path} -r stackprof/autorun #{ENV['RUBYOPT']}"
Kernel.exec(env, *ARGV)
else
options = {}
- parser = OptionParser.new(ARGV) do |o|
- o.banner = "Usage: stackprof run [--mode|--out|--interval] -- COMMAND"
- o.banner = "Usage: stackprof [file.dump]+ [--text|--method=NAME|--callgrind|--graphviz]"
-
+ parser = OptionParser.new(banner) do |o|
o.on('--text', 'Text summary per method (default)'){ options[:format] = :text }
o.on('--json', 'JSON output (use with web viewers)'){ options[:format] = :json }
o.on('--files', 'List of files'){ |f| options[:format] = :files }
o.on('--limit [num]', Integer, 'Limit --text, --files, or --graphviz output to N entries'){ |n| options[:limit] = n }
o.on('--sort-total', "Sort --text or --files output on total samples\n\n"){ options[:sort] = true }