Skip to content

Instantly share code, notes, and snippets.

@yui-knk
Last active January 5, 2016 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yui-knk/17c5242773ed5c0e0cfe to your computer and use it in GitHub Desktop.
Save yui-knk/17c5242773ed5c0e0cfe to your computer and use it in GitHub Desktop.
# stackprof (0.2.7)
require 'stackprof'
class StackProfTest
def test_raw
profile = StackProf.run(mode: :custom, raw: true) do
10.times do
StackProf.sample
end
end
end
end
profile = StackProfTest.new.test_raw
p RUBY_VERSION
p StackProf::Report.new(profile).print_text
p profile
# Ruby 2.2.4
"2.2.4"
==================================
Mode: custom()
Samples: 10 (0.00% miss rate)
GC: 0 (0.00%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
10 (100.0%) 10 (100.0%) block (2 levels) in StackProfTest#test_raw
10 (100.0%) 0 (0.0%) StackProfTest#test_raw
10 (100.0%) 0 (0.0%) block in StackProfTest#test_raw
10 (100.0%) 0 (0.0%) <main>
10 (100.0%) 0 (0.0%) <main>
{70119472506200=>{:name=>"block (2 levels) in StackProfTest#test_raw", :file=>"compare_stackprof.rb", :line=>6, :total_samples=>10, :samples=>10, :lines=>{7=>[10, 10]}}, 70119472506480=>{:name=>"StackProfTest#test_raw", :file=>"compare_stackprof.rb", :line=>4, :total_samples=>10, :samples=>0, :edges=>{70119472506360=>10}, :lines=>{5=>[10, 0]}}, 70119472506360=>{:name=>"block in StackProfTest#test_raw", :file=>"compare_stackprof.rb", :line=>5, :total_samples=>10, :samples=>0, :edges=>{70119472506200=>10}, :lines=>{6=>[10, 0]}}, 70119472506680=>{:name=>"<main>", :file=>"compare_stackprof.rb", :total_samples=>10, :samples=>0, :edges=>{70119472506480=>10}, :lines=>{13=>[10, 0]}}, 70119460094540=>{:name=>"<main>", :file=>"sample2.rb", :total_samples=>10, :samples=>0, :edges=>{70119472506680=>10}}}
{:version=>1.1, :mode=>:custom, :interval=>nil, :samples=>10, :gc_samples=>0, :missed_samples=>0, :frames=>{70119472506200=>{:name=>"block (2 levels) in StackProfTest#test_raw", :file=>"compare_stackprof.rb", :line=>6, :total_samples=>10, :samples=>10, :lines=>{7=>[10, 10]}}, 70119472506360=>{:name=>"block in StackProfTest#test_raw", :file=>"compare_stackprof.rb", :line=>5, :total_samples=>10, :samples=>0, :edges=>{70119472506200=>10}, :lines=>{6=>[10, 0]}}, 70119472506480=>{:name=>"StackProfTest#test_raw", :file=>"compare_stackprof.rb", :line=>4, :total_samples=>10, :samples=>0, :edges=>{70119472506360=>10}, :lines=>{5=>[10, 0]}}, 70119472506680=>{:name=>"<main>", :file=>"compare_stackprof.rb", :total_samples=>10, :samples=>0, :edges=>{70119472506480=>10}, :lines=>{13=>[10, 0]}}, 70119460094540=>{:name=>"<main>", :file=>"sample2.rb", :total_samples=>10, :samples=>0, :edges=>{70119472506680=>10}}}, :raw=>[5, 70119460094540, 70119472506680, 70119472506480, 70119472506360, 70119472506200, 10]}
# Ruby 2.3.0
"2.3.0"
==================================
Mode: custom()
Samples: 10 (0.00% miss rate)
GC: 0 (0.00%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
30 (300.0%) 10 (100.0%) StackProfTest#test_raw
10 (100.0%) 0 (0.0%) <main>
10 (100.0%) 0 (0.0%) <main>
{70314349288560=>{:name=>"StackProfTest#test_raw", :file=>"compare_stackprof.rb", :line=>4, :total_samples=>30, :samples=>10, :edges=>{70314349288560=>20}, :lines=>{7=>[10, 10], 6=>[10, 0], 5=>[10, 0]}}, 70314349305440=>{:name=>"<main>", :file=>"compare_stackprof.rb", :total_samples=>10, :samples=>0, :edges=>{70314349288560=>10}, :lines=>{13=>[10, 0]}}, 70314348518020=>{:name=>"<main>", :file=>"sample2.rb", :total_samples=>10, :samples=>0, :edges=>{70314349305440=>10}}}
{:version=>1.1, :mode=>:custom, :interval=>nil, :samples=>10, :gc_samples=>0, :missed_samples=>0, :frames=>{70314349288560=>{:name=>"StackProfTest#test_raw", :file=>"compare_stackprof.rb", :line=>4, :total_samples=>30, :samples=>10, :edges=>{70314349288560=>20}, :lines=>{7=>[10, 10], 6=>[10, 0], 5=>[10, 0]}}, 70314349305440=>{:name=>"<main>", :file=>"compare_stackprof.rb", :total_samples=>10, :samples=>0, :edges=>{70314349288560=>10}, :lines=>{13=>[10, 0]}}, 70314348518020=>{:name=>"<main>", :file=>"sample2.rb", :total_samples=>10, :samples=>0, :edges=>{70314349305440=>10}}}, :raw=>[5, 70314348518020, 70314349305440, 70314349288560, 70314349288560, 70314349288560, 10]}
@yui-knk
Copy link
Author

yui-knk commented Jan 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment