Sha256: 649a50f57954059d5094eb46b108d7df9d5597b4709b414e7ceb952ace900302

Contents?: true

Size: 924 Bytes

Versions: 1

Compression:

Stored size: 924 Bytes

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'stackprof'

opt = OptionParser.new

mode = ENV['STACKPROF_MODE']&.to_sym || :cpu
out = ENV['STACKPROF_OUT'] || 'stackprof-out'
interval = nil
aggregate = true
raw = false

opt.banner = 'Usage: stackprof-run [options] command [command options]'
opt.on('-m MODE', '--mode=MODE', ':cpu(default), :wall, :object'){|v| mode = v.to_sym}
opt.on('-o FILE', '--out=FILE', 'Output file name. (default: stackprof-out)'){|v| out = v}
opt.on('-i INTERVAL', '--interval=INTERVAL'){|v| interval = v.to_i}
opt.on('-no-aggregate'){|v| aggregate = false}
opt.on('-r', '--raw'){|v| raw = true}

opt.order!(ARGV)

cmd = ARGV.shift
unless cmd
  puts opt.help
  exit 1
end

path = `which #{cmd}`.chomp

$PROGRAM_NAME = cmd

ex = nil
StackProf.run(mode: mode, out: out, interval: interval, aggregate: aggregate, raw: raw) do
  begin
    load path
  rescue Exception => ex
  end
end

raise ex if ex

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stackprof-run-0.3.0 exe/stackprof-run