File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -40,15 +40,21 @@ def run_benchmark(*)
4040 block_trace . disable
4141 method_trace . disable
4242
43- puts "Top C method block iterations:"
44- c_loops . sort_by ( &:last ) . reverse_each do |method , count |
45- puts '%8d %s' % [ count , method ]
43+ c_loops_total = c_loops . sum ( &:last )
44+ c_loops = c_loops . sort_by { |_method , count | -count } . first ( 100 )
45+ c_loops_ratio = 100.0 * c_loops . sum ( &:last ) / c_loops_total
46+ puts "Top #{ c_loops . size } block calls by C methods (#{ '%.1f' % c_loops_ratio } % of all #{ c_loops_total } calls):"
47+ c_loops . each do |method , count |
48+ puts '%8d (%4.1f%%) %s' % [ count , 100.0 * count / c_loops_total , method ]
4649 end
4750 puts
4851
49- puts "Top 100 C method calls:"
52+ c_calls_total = c_calls . sum ( &:last )
53+ c_calls = c_calls . sort_by { |_method , count | -count } . first ( 100 )
54+ c_calls_ratio = 100.0 * c_calls . sum ( &:last ) / c_calls_total
55+ puts "Top #{ c_calls . size } C method calls (#{ '%.1f' % c_calls_ratio } % of all #{ c_calls_total } calls):"
5056 c_calls . sort_by ( &:last ) . reverse . first ( 100 ) . each do |method , count |
51- puts '%8d % s' % [ count , method ]
57+ puts '%8d (%4.1f%%) % s' % [ count , 100.0 * count / c_calls_total , method ]
5258 end
5359 end
5460}
You can’t perform that action at this time.
0 commit comments