diff --git a/lib/stackprof/report.rb b/lib/stackprof/report.rb index 2f8177b6..afcbd928 100644 --- a/lib/stackprof/report.rb +++ b/lib/stackprof/report.rb @@ -73,15 +73,15 @@ def print_json(f=STDOUT) f.puts JSON.generate(@data, max_nesting: false) end - def print_stackcollapse + def print_stackcollapse(f=STDOUT) raise "profile does not include raw samples (add `raw: true` to collecting StackProf.run)" unless raw = data[:raw] while len = raw.shift frames = raw.slice!(0, len) weight = raw.shift - print frames.map{ |a| data[:frames][a][:name] }.join(';') - puts " #{weight}" + f.print frames.map{ |a| data[:frames][a][:name] }.join(';') + f.puts " #{weight}" end end