ruby-prof 0.15.9 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +27 -1
- data/README.rdoc +83 -31
- data/bin/ruby-prof +4 -4
- data/doc/LICENSE.html +1 -1
- data/doc/README_rdoc.html +92 -33
- data/doc/Rack.html +1 -1
- data/doc/Rack/RubyProf.html +17 -14
- data/doc/RubyProf.html +30 -29
- data/doc/RubyProf/AbstractPrinter.html +1 -1
- data/doc/RubyProf/AggregateCallInfo.html +1 -1
- data/doc/RubyProf/CallInfo.html +1 -1
- data/doc/RubyProf/CallInfoPrinter.html +1 -1
- data/doc/RubyProf/CallInfoVisitor.html +1 -1
- data/doc/RubyProf/CallStackPrinter.html +1 -1
- data/doc/RubyProf/CallTreePrinter.html +349 -67
- data/doc/RubyProf/Cmd.html +5 -5
- data/doc/RubyProf/DotPrinter.html +2 -2
- data/doc/RubyProf/FlatPrinter.html +1 -1
- data/doc/RubyProf/FlatPrinterWithLineNumbers.html +1 -1
- data/doc/RubyProf/GraphHtmlPrinter.html +1 -1
- data/doc/RubyProf/GraphPrinter.html +1 -1
- data/doc/RubyProf/MethodInfo.html +2 -2
- data/doc/RubyProf/MultiPrinter.html +11 -9
- data/doc/RubyProf/Profile.html +94 -44
- data/doc/RubyProf/ProfileTask.html +1 -1
- data/doc/RubyProf/Thread.html +43 -1
- data/doc/created.rid +16 -16
- data/doc/examples/flat_txt.html +1 -1
- data/doc/examples/graph_html.html +1 -1
- data/doc/examples/graph_txt.html +3 -3
- data/doc/index.html +85 -30
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +2 -2
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +117 -68
- data/examples/cachegrind.out.1 +114 -0
- data/examples/cachegrind.out.1.32313213 +114 -0
- data/examples/graph.txt +1 -1
- data/ext/ruby_prof/extconf.rb +6 -2
- data/ext/ruby_prof/rp_measure_cpu_time.c +29 -31
- data/ext/ruby_prof/rp_method.c +1 -1
- data/ext/ruby_prof/rp_thread.c +57 -52
- data/ext/ruby_prof/ruby_prof.c +122 -66
- data/ext/ruby_prof/ruby_prof.h +2 -0
- data/lib/ruby-prof.rb +14 -13
- data/lib/ruby-prof/assets/call_stack_printer.js.html +1 -1
- data/lib/ruby-prof/compatibility.rb +9 -8
- data/lib/ruby-prof/method_info.rb +1 -1
- data/lib/ruby-prof/printers/call_tree_printer.rb +88 -50
- data/lib/ruby-prof/printers/dot_printer.rb +1 -1
- data/lib/ruby-prof/printers/multi_printer.rb +6 -4
- data/lib/ruby-prof/profile.rb +0 -1
- data/lib/ruby-prof/rack.rb +53 -16
- data/lib/ruby-prof/thread.rb +11 -0
- data/lib/ruby-prof/version.rb +1 -1
- data/test/exclude_threads_test.rb +2 -3
- data/test/fiber_test.rb +21 -7
- data/test/measure_cpu_time_test.rb +84 -24
- data/test/multi_printer_test.rb +5 -4
- data/test/pause_resume_test.rb +7 -7
- data/test/printers_test.rb +6 -4
- data/test/rack_test.rb +26 -1
- data/test/test_helper.rb +28 -3
- data/test/thread_test.rb +1 -0
- metadata +5 -3
data/doc/Rack.html
CHANGED
@@ -89,7 +89,7 @@
|
|
89
89
|
|
90
90
|
<footer id="validator-badges" role="contentinfo">
|
91
91
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
92
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.
|
92
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
93
93
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
94
94
|
</footer>
|
95
95
|
|
data/doc/Rack/RubyProf.html
CHANGED
@@ -141,7 +141,8 @@
|
|
141
141
|
<span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GraphHtmlPrinter</span> =<span class="ruby-operator">></span> <span class="ruby-string">'graph.html'</span>,
|
142
142
|
<span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">CallStackPrinter</span> =<span class="ruby-operator">></span> <span class="ruby-string">'call_stack.html'</span>}
|
143
143
|
|
144
|
-
<span class="ruby-ivar">@skip_paths</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:skip_paths</span>] <span class="ruby-operator">||</span> [<span class="ruby-regexp">%r{^/assets}</span>, <span class="ruby-regexp">%r{\.css
|
144
|
+
<span class="ruby-ivar">@skip_paths</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:skip_paths</span>] <span class="ruby-operator">||</span> [<span class="ruby-regexp">%r{^/assets}</span>, <span class="ruby-regexp">%r{\.(css|js|png|jpeg|jpg|gif)$}</span>]
|
145
|
+
<span class="ruby-ivar">@only_paths</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:only_paths</span>]
|
145
146
|
<span class="ruby-keyword">end</span></pre>
|
146
147
|
</div>
|
147
148
|
|
@@ -180,23 +181,25 @@
|
|
180
181
|
|
181
182
|
|
182
183
|
<div class="method-source-code" id="call-source">
|
183
|
-
<pre><span class="ruby-comment"># File lib/ruby-prof/rack.rb, line
|
184
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/rack.rb, line 22</span>
|
184
185
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
|
185
186
|
<span class="ruby-identifier">request</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
|
186
187
|
|
187
|
-
<span class="ruby-keyword">if</span> <span class="ruby-
|
188
|
-
<span class="ruby-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
<span class="ruby-
|
193
|
-
<span class="ruby-keyword">end</span>
|
188
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">should_profile?</span>(<span class="ruby-identifier">request</span>.<span class="ruby-identifier">path</span>)
|
189
|
+
<span class="ruby-keyword">begin</span>
|
190
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-keyword">nil</span>
|
191
|
+
<span class="ruby-identifier">data</span> = <span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">Profile</span>.<span class="ruby-identifier">profile</span>(<span class="ruby-identifier">profiling_options</span>) <span class="ruby-keyword">do</span>
|
192
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
|
193
|
+
<span class="ruby-keyword">end</span>
|
194
194
|
|
195
|
-
|
196
|
-
|
195
|
+
<span class="ruby-identifier">path</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'/'</span>, <span class="ruby-string">'-'</span>)
|
196
|
+
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">0</span>)
|
197
197
|
|
198
|
-
|
199
|
-
|
198
|
+
<span class="ruby-identifier">print</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">path</span>)
|
199
|
+
<span class="ruby-identifier">result</span>
|
200
|
+
<span class="ruby-keyword">end</span>
|
201
|
+
<span class="ruby-keyword">else</span>
|
202
|
+
<span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
|
200
203
|
<span class="ruby-keyword">end</span>
|
201
204
|
<span class="ruby-keyword">end</span></pre>
|
202
205
|
</div>
|
@@ -217,7 +220,7 @@
|
|
217
220
|
|
218
221
|
<footer id="validator-badges" role="contentinfo">
|
219
222
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
220
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.
|
223
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
221
224
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
222
225
|
</footer>
|
223
226
|
|
data/doc/RubyProf.html
CHANGED
@@ -297,7 +297,7 @@ environment variable</p>
|
|
297
297
|
|
298
298
|
|
299
299
|
<div class="method-source-code" id="figure_measure_mode-source">
|
300
|
-
<pre><span class="ruby-comment"># File lib/ruby-prof.rb, line
|
300
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof.rb, line 35</span>
|
301
301
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">figure_measure_mode</span>
|
302
302
|
<span class="ruby-keyword">case</span> <span class="ruby-constant">ENV</span>[<span class="ruby-string">"RUBY_PROF_MEASURE_MODE"</span>]
|
303
303
|
<span class="ruby-keyword">when</span> <span class="ruby-string">"wall"</span>, <span class="ruby-string">"wall_time"</span>
|
@@ -511,17 +511,17 @@ environment variable</p>
|
|
511
511
|
|
512
512
|
<p>Returns what ruby-prof is measuring. Valid values include:</p>
|
513
513
|
|
514
|
-
<p>*RubyProf::
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
514
|
+
<p>*RubyProf::WALL_TIME - Measure wall time using gettimeofday on Linx and
|
515
|
+
GetLocalTime on Windows. This is default. *RubyProf::PROCESS_TIME -
|
516
|
+
Measure process time. It is implemented using the clock functions in the C
|
517
|
+
Runtime library. *RubyProf::CPU_TIME - Measure time using the CPU clock
|
518
|
+
counter. This mode is only supported on Pentium or PowerPC platforms.
|
519
|
+
*RubyProf::ALLOCATIONS - Measure object allocations. This requires a
|
520
|
+
patched Ruby interpreter. *RubyProf::MEMORY - Measure memory size. This
|
521
|
+
requires a patched Ruby interpreter. *RubyProf::GC_RUNS - Measure number of
|
522
|
+
garbage collections. This requires a patched Ruby interpreter.
|
523
|
+
*RubyProf::GC_TIME - Measure time spent doing garbage collection. This
|
524
|
+
requires a patched Ruby interpreter.*/</p>
|
525
525
|
|
526
526
|
|
527
527
|
|
@@ -559,17 +559,17 @@ collection. This requires a patched Ruby interpreter.*/</p>
|
|
559
559
|
|
560
560
|
<p>Specifies what ruby-prof should measure. Valid values include:</p>
|
561
561
|
|
562
|
-
<p>*RubyProf::
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
562
|
+
<p>*RubyProf::WALL_TIME - Measure wall time using gettimeofday on Linx and
|
563
|
+
GetLocalTime on Windows. This is default. *RubyProf::PROCESS_TIME -
|
564
|
+
Measure process time. It is implemented using the clock functions in the C
|
565
|
+
Runtime library. *RubyProf::CPU_TIME - Measure time using the CPU clock
|
566
|
+
counter. This mode is only supported on Pentium or PowerPC platforms.
|
567
|
+
*RubyProf::ALLOCATIONS - Measure object allocations. This requires a
|
568
|
+
patched Ruby interpreter. *RubyProf::MEMORY - Measure memory size. This
|
569
|
+
requires a patched Ruby interpreter. *RubyProf::GC_RUNS - Measure number of
|
570
|
+
garbage collections. This requires a patched Ruby interpreter.
|
571
|
+
*RubyProf::GC_TIME - Measure time spent doing garbage collection. This
|
572
|
+
requires a patched Ruby interpreter.*/</p>
|
573
573
|
|
574
574
|
|
575
575
|
|
@@ -735,7 +735,7 @@ collection. This requires a patched Ruby interpreter.*/</p>
|
|
735
735
|
|
736
736
|
<div class="method-heading">
|
737
737
|
<span class="method-name">profile</span><span
|
738
|
-
class="method-args">(&block)</span>
|
738
|
+
class="method-args">(options = {}, &block)</span>
|
739
739
|
|
740
740
|
<span class="method-click-advice">click to toggle source</span>
|
741
741
|
|
@@ -751,12 +751,13 @@ collection. This requires a patched Ruby interpreter.*/</p>
|
|
751
751
|
|
752
752
|
<div class="method-source-code" id="profile-source">
|
753
753
|
<pre><span class="ruby-comment"># File lib/ruby-prof/compatibility.rb, line 142</span>
|
754
|
-
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">profile</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
754
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">profile</span>(<span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
755
755
|
<span class="ruby-identifier">ensure_not_running!</span>
|
756
756
|
<span class="ruby-identifier">gc_stat_was_enabled</span> = <span class="ruby-identifier">enable_gc_stats_if_needed</span>
|
757
|
-
<span class="ruby-identifier">
|
757
|
+
<span class="ruby-identifier">options</span> = { <span class="ruby-identifier">measure_mode</span><span class="ruby-operator">:</span> <span class="ruby-identifier">measure_mode</span>, <span class="ruby-identifier">exclude_threads</span><span class="ruby-operator">:</span> <span class="ruby-identifier">exclude_threads</span> }.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">options</span>)
|
758
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-constant">Profile</span>.<span class="ruby-identifier">profile</span>(<span class="ruby-identifier">options</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
758
759
|
<span class="ruby-identifier">disable_gc_stats_if_needed</span>(<span class="ruby-identifier">gc_stat_was_enabled</span>)
|
759
|
-
<span class="ruby-identifier">
|
760
|
+
<span class="ruby-identifier">result</span>
|
760
761
|
<span class="ruby-keyword">end</span></pre>
|
761
762
|
</div>
|
762
763
|
|
@@ -862,7 +863,7 @@ collection. This requires a patched Ruby interpreter.*/</p>
|
|
862
863
|
<pre><span class="ruby-comment"># File lib/ruby-prof/compatibility.rb, line 106</span>
|
863
864
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">start</span>
|
864
865
|
<span class="ruby-identifier">ensure_not_running!</span>
|
865
|
-
<span class="ruby-ivar">@profile</span> = <span class="ruby-constant">Profile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-
|
866
|
+
<span class="ruby-ivar">@profile</span> = <span class="ruby-constant">Profile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">measure_mode</span><span class="ruby-operator">:</span> <span class="ruby-identifier">measure_mode</span>, <span class="ruby-identifier">exclude_threads</span><span class="ruby-operator">:</span> <span class="ruby-identifier">exclude_threads</span>)
|
866
867
|
<span class="ruby-identifier">enable_gc_stats_if_needed</span>
|
867
868
|
<span class="ruby-ivar">@profile</span>.<span class="ruby-identifier">start</span>
|
868
869
|
<span class="ruby-keyword">end</span></pre>
|
@@ -955,7 +956,7 @@ collection. This requires a patched Ruby interpreter.*/</p>
|
|
955
956
|
|
956
957
|
<footer id="validator-badges" role="contentinfo">
|
957
958
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
958
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.
|
959
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
959
960
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
960
961
|
</footer>
|
961
962
|
|
@@ -540,7 +540,7 @@ options.</p>
|
|
540
540
|
|
541
541
|
<footer id="validator-badges" role="contentinfo">
|
542
542
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
543
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.
|
543
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
544
544
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
545
545
|
</footer>
|
546
546
|
|
@@ -545,7 +545,7 @@
|
|
545
545
|
|
546
546
|
<footer id="validator-badges" role="contentinfo">
|
547
547
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
548
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.
|
548
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
549
549
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
550
550
|
</footer>
|
551
551
|
|
data/doc/RubyProf/CallInfo.html
CHANGED
@@ -633,7 +633,7 @@ merges children of other into children of self.</p>
|
|
633
633
|
|
634
634
|
<footer id="validator-badges" role="contentinfo">
|
635
635
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
636
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.
|
636
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
637
637
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
638
638
|
</footer>
|
639
639
|
|
@@ -114,7 +114,7 @@ into RubyProf's internals.</p>
|
|
114
114
|
|
115
115
|
<footer id="validator-badges" role="contentinfo">
|
116
116
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
117
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.
|
117
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
118
118
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
119
119
|
</footer>
|
120
120
|
|
@@ -192,7 +192,7 @@
|
|
192
192
|
|
193
193
|
<footer id="validator-badges" role="contentinfo">
|
194
194
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
195
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.
|
195
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
196
196
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
197
197
|
</footer>
|
198
198
|
|
@@ -1115,7 +1115,7 @@ end_title_bar</span>
|
|
1115
1115
|
|
1116
1116
|
<footer id="validator-badges" role="contentinfo">
|
1117
1117
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
1118
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.
|
1118
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
1119
1119
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
1120
1120
|
</footer>
|
1121
1121
|
|
@@ -70,16 +70,32 @@
|
|
70
70
|
|
71
71
|
<ul class="link-list" role="directory">
|
72
72
|
|
73
|
+
<li ><a href="#method-i-base_name">#base_name</a>
|
74
|
+
|
73
75
|
<li ><a href="#method-i-convert">#convert</a>
|
74
76
|
|
77
|
+
<li ><a href="#method-i-determine_event_specification_and_value_scale">#determine_event_specification_and_value_scale</a>
|
78
|
+
|
75
79
|
<li ><a href="#method-i-file">#file</a>
|
76
80
|
|
81
|
+
<li ><a href="#method-i-file_name_for_thread">#file_name_for_thread</a>
|
82
|
+
|
83
|
+
<li ><a href="#method-i-file_path_for_thread">#file_path_for_thread</a>
|
84
|
+
|
85
|
+
<li ><a href="#method-i-path">#path</a>
|
86
|
+
|
77
87
|
<li ><a href="#method-i-print">#print</a>
|
78
88
|
|
89
|
+
<li ><a href="#method-i-print_headers">#print_headers</a>
|
90
|
+
|
91
|
+
<li ><a href="#method-i-print_method">#print_method</a>
|
92
|
+
|
79
93
|
<li ><a href="#method-i-print_thread">#print_thread</a>
|
80
94
|
|
81
95
|
<li ><a href="#method-i-print_threads">#print_threads</a>
|
82
96
|
|
97
|
+
<li ><a href="#method-i-remove_subsidiary_files_from_previous_profile_runs">#remove_subsidiary_files_from_previous_profile_runs</a>
|
98
|
+
|
83
99
|
</ul>
|
84
100
|
</div>
|
85
101
|
|
@@ -93,9 +109,13 @@
|
|
93
109
|
|
94
110
|
<section class="description">
|
95
111
|
|
96
|
-
<p>Generate profiling information in
|
112
|
+
<p>Generate profiling information in callgrind format for use by kcachegrind
|
97
113
|
and similar tools.</p>
|
98
114
|
|
115
|
+
<p>Note: when profiling for a callgrind printer, one should use the
|
116
|
+
merge_fibers: true option when creating the profile. Otherwise each fiber
|
117
|
+
would appear as a separate profile.</p>
|
118
|
+
|
99
119
|
</section>
|
100
120
|
|
101
121
|
|
@@ -117,11 +137,11 @@ and similar tools.</p>
|
|
117
137
|
</header>
|
118
138
|
|
119
139
|
|
120
|
-
<div id="method-i-
|
140
|
+
<div id="method-i-base_name" class="method-detail ">
|
121
141
|
|
122
142
|
<div class="method-heading">
|
123
|
-
<span class="method-name">
|
124
|
-
class="method-args">(
|
143
|
+
<span class="method-name">base_name</span><span
|
144
|
+
class="method-args">()</span>
|
125
145
|
|
126
146
|
<span class="method-click-advice">click to toggle source</span>
|
127
147
|
|
@@ -135,10 +155,10 @@ and similar tools.</p>
|
|
135
155
|
|
136
156
|
|
137
157
|
|
138
|
-
<div class="method-source-code" id="
|
139
|
-
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line
|
140
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">
|
141
|
-
|
158
|
+
<div class="method-source-code" id="base_name-source">
|
159
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 81</span>
|
160
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">base_name</span>
|
161
|
+
<span class="ruby-ivar">@options</span>[<span class="ruby-value">:profile</span>] <span class="ruby-operator">||</span> <span class="ruby-string">"profile"</span>
|
142
162
|
<span class="ruby-keyword">end</span></pre>
|
143
163
|
</div>
|
144
164
|
|
@@ -150,11 +170,11 @@ and similar tools.</p>
|
|
150
170
|
</div>
|
151
171
|
|
152
172
|
|
153
|
-
<div id="method-i-
|
173
|
+
<div id="method-i-convert" class="method-detail ">
|
154
174
|
|
155
175
|
<div class="method-heading">
|
156
|
-
<span class="method-name">
|
157
|
-
class="method-args">(
|
176
|
+
<span class="method-name">convert</span><span
|
177
|
+
class="method-args">(value)</span>
|
158
178
|
|
159
179
|
<span class="method-click-advice">click to toggle source</span>
|
160
180
|
|
@@ -168,10 +188,10 @@ and similar tools.</p>
|
|
168
188
|
|
169
189
|
|
170
190
|
|
171
|
-
<div class="method-source-code" id="
|
172
|
-
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line
|
173
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">
|
174
|
-
<span class="ruby-
|
191
|
+
<div class="method-source-code" id="convert-source">
|
192
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 60</span>
|
193
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">convert</span>(<span class="ruby-identifier">value</span>)
|
194
|
+
(<span class="ruby-identifier">value</span> <span class="ruby-operator">*</span> <span class="ruby-ivar">@value_scale</span>).<span class="ruby-identifier">round</span>
|
175
195
|
<span class="ruby-keyword">end</span></pre>
|
176
196
|
</div>
|
177
197
|
|
@@ -183,11 +203,11 @@ and similar tools.</p>
|
|
183
203
|
</div>
|
184
204
|
|
185
205
|
|
186
|
-
<div id="method-i-
|
206
|
+
<div id="method-i-determine_event_specification_and_value_scale" class="method-detail ">
|
187
207
|
|
188
208
|
<div class="method-heading">
|
189
|
-
<span class="method-name">
|
190
|
-
class="method-args">(
|
209
|
+
<span class="method-name">determine_event_specification_and_value_scale</span><span
|
210
|
+
class="method-args">()</span>
|
191
211
|
|
192
212
|
<span class="method-click-advice">click to toggle source</span>
|
193
213
|
|
@@ -196,57 +216,210 @@ and similar tools.</p>
|
|
196
216
|
|
197
217
|
<div class="method-description">
|
198
218
|
|
199
|
-
<p>Specify print options.</p>
|
200
|
-
|
201
|
-
<p>options - Hash table</p>
|
202
|
-
|
203
|
-
<pre>:min_percent - Number 0 to 100 that specifes the minimum
|
204
|
-
%self (the methods self time divided by the
|
205
|
-
overall total time) that a method must take
|
206
|
-
for it to be printed out in the report.
|
207
|
-
Default value is 0.
|
208
|
-
|
209
|
-
:print_file - True or false. Specifies if a method's source
|
210
|
-
file should be printed. Default value if false.</pre>
|
211
219
|
|
212
220
|
|
213
|
-
|
214
221
|
|
215
|
-
<div class="method-source-code" id="print-source">
|
216
|
-
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 19</span>
|
217
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">print</span>(<span class="ruby-identifier">output</span> = <span class="ruby-constant">STDOUT</span>, <span class="ruby-identifier">options</span> = {})
|
218
|
-
<span class="ruby-ivar">@output</span> = <span class="ruby-identifier">output</span>
|
219
|
-
<span class="ruby-identifier">setup_options</span>(<span class="ruby-identifier">options</span>)
|
220
222
|
|
221
|
-
|
222
|
-
|
223
|
+
|
224
|
+
<div class="method-source-code" id="determine_event_specification_and_value_scale-source">
|
225
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 16</span>
|
226
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">determine_event_specification_and_value_scale</span>
|
227
|
+
<span class="ruby-ivar">@event_specification</span> = <span class="ruby-string">"events: "</span>
|
223
228
|
<span class="ruby-keyword">case</span> <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span>
|
224
229
|
<span class="ruby-keyword">when</span> <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">PROCESS_TIME</span>
|
225
|
-
<span class="ruby-ivar">@value_scale</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">CLOCKS_PER_SEC</span
|
226
|
-
<span class="ruby-ivar">@
|
230
|
+
<span class="ruby-ivar">@value_scale</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">CLOCKS_PER_SEC</span>
|
231
|
+
<span class="ruby-ivar">@event_specification</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'process_time'</span>
|
227
232
|
<span class="ruby-keyword">when</span> <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">WALL_TIME</span>
|
228
233
|
<span class="ruby-ivar">@value_scale</span> = <span class="ruby-value">1_000_000</span>
|
229
|
-
<span class="ruby-ivar">@
|
234
|
+
<span class="ruby-ivar">@event_specification</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'wall_time'</span>
|
230
235
|
<span class="ruby-keyword">when</span> <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:CPU_TIME</span>) <span class="ruby-operator">&&</span> <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">CPU_TIME</span>
|
231
236
|
<span class="ruby-ivar">@value_scale</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">cpu_frequency</span>
|
232
|
-
<span class="ruby-ivar">@
|
237
|
+
<span class="ruby-ivar">@event_specification</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'cpu_time'</span>
|
233
238
|
<span class="ruby-keyword">when</span> <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:ALLOCATIONS</span>) <span class="ruby-operator">&&</span> <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">ALLOCATIONS</span>
|
234
239
|
<span class="ruby-ivar">@value_scale</span> = <span class="ruby-value">1</span>
|
235
|
-
<span class="ruby-ivar">@
|
240
|
+
<span class="ruby-ivar">@event_specification</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'allocations'</span>
|
236
241
|
<span class="ruby-keyword">when</span> <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:MEMORY</span>) <span class="ruby-operator">&&</span> <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">MEMORY</span>
|
237
242
|
<span class="ruby-ivar">@value_scale</span> = <span class="ruby-value">1</span>
|
238
|
-
<span class="ruby-ivar">@
|
243
|
+
<span class="ruby-ivar">@event_specification</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'memory'</span>
|
239
244
|
<span class="ruby-keyword">when</span> <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:GC_RUNS</span>) <span class="ruby-operator">&&</span> <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GC_RUNS</span>
|
240
245
|
<span class="ruby-ivar">@value_scale</span> = <span class="ruby-value">1</span>
|
241
|
-
<span class="ruby-ivar">@
|
246
|
+
<span class="ruby-ivar">@event_specification</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'gc_runs'</span>
|
242
247
|
<span class="ruby-keyword">when</span> <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-value">:GC_TIME</span>) <span class="ruby-operator">&&</span> <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GC_TIME</span>
|
243
248
|
<span class="ruby-ivar">@value_scale</span> = <span class="ruby-value">1000000</span>
|
244
|
-
<span class="ruby-ivar">@
|
249
|
+
<span class="ruby-ivar">@event_specification</span> <span class="ruby-operator"><<</span> <span class="ruby-string">'gc_time'</span>
|
245
250
|
<span class="ruby-keyword">else</span>
|
246
251
|
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Unknown measure mode: #{RubyProf.measure_mode}"</span>
|
247
252
|
<span class="ruby-keyword">end</span>
|
248
|
-
|
253
|
+
<span class="ruby-keyword">end</span></pre>
|
254
|
+
</div>
|
255
|
+
|
256
|
+
</div>
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
</div>
|
262
|
+
|
263
|
+
|
264
|
+
<div id="method-i-file" class="method-detail ">
|
265
|
+
|
266
|
+
<div class="method-heading">
|
267
|
+
<span class="method-name">file</span><span
|
268
|
+
class="method-args">(method)</span>
|
269
|
+
|
270
|
+
<span class="method-click-advice">click to toggle source</span>
|
271
|
+
|
272
|
+
</div>
|
273
|
+
|
274
|
+
|
275
|
+
<div class="method-description">
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
<div class="method-source-code" id="file-source">
|
283
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 64</span>
|
284
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">file</span>(<span class="ruby-identifier">method</span>)
|
285
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">method</span>.<span class="ruby-identifier">source_file</span>)
|
286
|
+
<span class="ruby-keyword">end</span></pre>
|
287
|
+
</div>
|
288
|
+
|
289
|
+
</div>
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
</div>
|
295
|
+
|
296
|
+
|
297
|
+
<div id="method-i-file_name_for_thread" class="method-detail ">
|
298
|
+
|
299
|
+
<div class="method-heading">
|
300
|
+
<span class="method-name">file_name_for_thread</span><span
|
301
|
+
class="method-args">(thread)</span>
|
302
|
+
|
303
|
+
<span class="method-click-advice">click to toggle source</span>
|
304
|
+
|
305
|
+
</div>
|
306
|
+
|
307
|
+
|
308
|
+
<div class="method-description">
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
<div class="method-source-code" id="file_name_for_thread-source">
|
316
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 91</span>
|
317
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">file_name_for_thread</span>(<span class="ruby-identifier">thread</span>)
|
318
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">fiber_id</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Fiber</span>.<span class="ruby-identifier">current</span>.<span class="ruby-identifier">object_id</span>
|
319
|
+
[<span class="ruby-identifier">base_name</span>, <span class="ruby-string">"callgrind.out"</span>, <span class="ruby-identifier">$$</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">"."</span>)
|
320
|
+
<span class="ruby-keyword">else</span>
|
321
|
+
[<span class="ruby-identifier">base_name</span>, <span class="ruby-string">"callgrind.out"</span>, <span class="ruby-identifier">$$</span>, <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">fiber_id</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">"."</span>)
|
322
|
+
<span class="ruby-keyword">end</span>
|
323
|
+
<span class="ruby-keyword">end</span></pre>
|
324
|
+
</div>
|
325
|
+
|
326
|
+
</div>
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
</div>
|
332
|
+
|
333
|
+
|
334
|
+
<div id="method-i-file_path_for_thread" class="method-detail ">
|
335
|
+
|
336
|
+
<div class="method-heading">
|
337
|
+
<span class="method-name">file_path_for_thread</span><span
|
338
|
+
class="method-args">(thread)</span>
|
339
|
+
|
340
|
+
<span class="method-click-advice">click to toggle source</span>
|
341
|
+
|
342
|
+
</div>
|
343
|
+
|
344
|
+
|
345
|
+
<div class="method-description">
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
<div class="method-source-code" id="file_path_for_thread-source">
|
353
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 99</span>
|
354
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">file_path_for_thread</span>(<span class="ruby-identifier">thread</span>)
|
355
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">file_name_for_thread</span>(<span class="ruby-identifier">thread</span>))
|
356
|
+
<span class="ruby-keyword">end</span></pre>
|
357
|
+
</div>
|
358
|
+
|
359
|
+
</div>
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
</div>
|
365
|
+
|
366
|
+
|
367
|
+
<div id="method-i-path" class="method-detail ">
|
368
|
+
|
369
|
+
<div class="method-heading">
|
370
|
+
<span class="method-name">path</span><span
|
371
|
+
class="method-args">()</span>
|
372
|
+
|
373
|
+
<span class="method-click-advice">click to toggle source</span>
|
374
|
+
|
375
|
+
</div>
|
376
|
+
|
377
|
+
|
378
|
+
<div class="method-description">
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
<div class="method-source-code" id="path-source">
|
386
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 77</span>
|
387
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">path</span>
|
388
|
+
<span class="ruby-ivar">@options</span>[<span class="ruby-value">:path</span>] <span class="ruby-operator">||</span> <span class="ruby-string">"."</span>
|
389
|
+
<span class="ruby-keyword">end</span></pre>
|
390
|
+
</div>
|
391
|
+
|
392
|
+
</div>
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
</div>
|
398
|
+
|
399
|
+
|
400
|
+
<div id="method-i-print" class="method-detail ">
|
401
|
+
|
402
|
+
<div class="method-heading">
|
403
|
+
<span class="method-name">print</span><span
|
404
|
+
class="method-args">(options = {})</span>
|
405
|
+
|
406
|
+
<span class="method-click-advice">click to toggle source</span>
|
407
|
+
|
408
|
+
</div>
|
409
|
+
|
249
410
|
|
411
|
+
<div class="method-description">
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
<div class="method-source-code" id="print-source">
|
419
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 45</span>
|
420
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">print</span>(<span class="ruby-identifier">options</span> = {})
|
421
|
+
<span class="ruby-identifier">setup_options</span>(<span class="ruby-identifier">options</span>)
|
422
|
+
<span class="ruby-identifier">determine_event_specification_and_value_scale</span>
|
250
423
|
<span class="ruby-identifier">print_threads</span>
|
251
424
|
<span class="ruby-keyword">end</span></pre>
|
252
425
|
</div>
|
@@ -256,6 +429,90 @@ and similar tools.</p>
|
|
256
429
|
|
257
430
|
|
258
431
|
|
432
|
+
</div>
|
433
|
+
|
434
|
+
|
435
|
+
<div id="method-i-print_headers" class="method-detail ">
|
436
|
+
|
437
|
+
<div class="method-heading">
|
438
|
+
<span class="method-name">print_headers</span><span
|
439
|
+
class="method-args">(output, thread)</span>
|
440
|
+
|
441
|
+
<span class="method-click-advice">click to toggle source</span>
|
442
|
+
|
443
|
+
</div>
|
444
|
+
|
445
|
+
|
446
|
+
<div class="method-description">
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
<div class="method-source-code" id="print_headers-source">
|
454
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 103</span>
|
455
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">print_headers</span>(<span class="ruby-identifier">output</span>, <span class="ruby-identifier">thread</span>)
|
456
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{@event_specification}\n\n"</span>
|
457
|
+
<span class="ruby-comment"># this doesn't work. kcachegrind does not fully support the spec.</span>
|
458
|
+
<span class="ruby-comment"># output << "thread: #{thread.id}\n\n"</span>
|
459
|
+
<span class="ruby-keyword">end</span></pre>
|
460
|
+
</div>
|
461
|
+
|
462
|
+
</div>
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
</div>
|
468
|
+
|
469
|
+
|
470
|
+
<div id="method-i-print_method" class="method-detail ">
|
471
|
+
|
472
|
+
<div class="method-heading">
|
473
|
+
<span class="method-name">print_method</span><span
|
474
|
+
class="method-args">(output, method)</span>
|
475
|
+
|
476
|
+
<span class="method-click-advice">click to toggle source</span>
|
477
|
+
|
478
|
+
</div>
|
479
|
+
|
480
|
+
|
481
|
+
<div class="method-description">
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
<div class="method-source-code" id="print_method-source">
|
489
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 109</span>
|
490
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">print_method</span>(<span class="ruby-identifier">output</span>, <span class="ruby-identifier">method</span>)
|
491
|
+
<span class="ruby-comment"># Print out the file and method name</span>
|
492
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"fl=#{file(method)}\n"</span>
|
493
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"fn=#{method_name(method)}\n"</span>
|
494
|
+
|
495
|
+
<span class="ruby-comment"># Now print out the function line number and its self time</span>
|
496
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{method.line} #{convert(method.self_time)}\n"</span>
|
497
|
+
|
498
|
+
<span class="ruby-comment"># Now print out all the children methods</span>
|
499
|
+
<span class="ruby-identifier">method</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">callee</span><span class="ruby-operator">|</span>
|
500
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"cfl=#{file(callee.target)}\n"</span>
|
501
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"cfn=#{method_name(callee.target)}\n"</span>
|
502
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"calls=#{callee.called} #{callee.line}\n"</span>
|
503
|
+
|
504
|
+
<span class="ruby-comment"># Print out total times here!</span>
|
505
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{callee.line} #{convert(callee.total_time)}\n"</span>
|
506
|
+
<span class="ruby-keyword">end</span>
|
507
|
+
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"\n"</span>
|
508
|
+
<span class="ruby-keyword">end</span></pre>
|
509
|
+
</div>
|
510
|
+
|
511
|
+
</div>
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
|
259
516
|
</div>
|
260
517
|
|
261
518
|
|
@@ -278,26 +535,13 @@ and similar tools.</p>
|
|
278
535
|
|
279
536
|
|
280
537
|
<div class="method-source-code" id="print_thread-source">
|
281
|
-
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line
|
538
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 68</span>
|
282
539
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">print_thread</span>(<span class="ruby-identifier">thread</span>)
|
283
|
-
<span class="ruby-
|
284
|
-
<span class="ruby-
|
285
|
-
<span class="ruby-
|
286
|
-
|
287
|
-
|
288
|
-
<span class="ruby-comment"># Now print out the function line number and its self time</span>
|
289
|
-
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{method.line} #{convert(method.self_time)}\n"</span>
|
290
|
-
|
291
|
-
<span class="ruby-comment"># Now print out all the children methods</span>
|
292
|
-
<span class="ruby-identifier">method</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">callee</span><span class="ruby-operator">|</span>
|
293
|
-
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"cfl=#{file(callee.target)}\n"</span>
|
294
|
-
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"cfn=#{method_name(callee.target)}\n"</span>
|
295
|
-
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"calls=#{callee.called} #{callee.line}\n"</span>
|
296
|
-
|
297
|
-
<span class="ruby-comment"># Print out total times here!</span>
|
298
|
-
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"#{callee.line} #{convert(callee.total_time)}\n"</span>
|
540
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">file_path_for_thread</span>(<span class="ruby-identifier">thread</span>), <span class="ruby-string">"w"</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
541
|
+
<span class="ruby-identifier">print_headers</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">thread</span>)
|
542
|
+
<span class="ruby-identifier">thread</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">reverse_each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span>
|
543
|
+
<span class="ruby-identifier">print_method</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">method</span>)
|
299
544
|
<span class="ruby-keyword">end</span>
|
300
|
-
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"\n"</span>
|
301
545
|
<span class="ruby-keyword">end</span>
|
302
546
|
<span class="ruby-keyword">end</span></pre>
|
303
547
|
</div>
|
@@ -329,8 +573,11 @@ and similar tools.</p>
|
|
329
573
|
|
330
574
|
|
331
575
|
<div class="method-source-code" id="print_threads-source">
|
332
|
-
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line
|
576
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 51</span>
|
333
577
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">print_threads</span>
|
578
|
+
<span class="ruby-identifier">remove_subsidiary_files_from_previous_profile_runs</span>
|
579
|
+
<span class="ruby-comment"># TODO: merge fibers of a given thread here, instead of relying</span>
|
580
|
+
<span class="ruby-comment"># on the profiler to merge fibers.</span>
|
334
581
|
<span class="ruby-ivar">@result</span>.<span class="ruby-identifier">threads</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">thread</span><span class="ruby-operator">|</span>
|
335
582
|
<span class="ruby-identifier">print_thread</span>(<span class="ruby-identifier">thread</span>)
|
336
583
|
<span class="ruby-keyword">end</span>
|
@@ -342,6 +589,41 @@ and similar tools.</p>
|
|
342
589
|
|
343
590
|
|
344
591
|
|
592
|
+
</div>
|
593
|
+
|
594
|
+
|
595
|
+
<div id="method-i-remove_subsidiary_files_from_previous_profile_runs" class="method-detail ">
|
596
|
+
|
597
|
+
<div class="method-heading">
|
598
|
+
<span class="method-name">remove_subsidiary_files_from_previous_profile_runs</span><span
|
599
|
+
class="method-args">()</span>
|
600
|
+
|
601
|
+
<span class="method-click-advice">click to toggle source</span>
|
602
|
+
|
603
|
+
</div>
|
604
|
+
|
605
|
+
|
606
|
+
<div class="method-description">
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
|
613
|
+
<div class="method-source-code" id="remove_subsidiary_files_from_previous_profile_runs-source">
|
614
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/call_tree_printer.rb, line 85</span>
|
615
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">remove_subsidiary_files_from_previous_profile_runs</span>
|
616
|
+
<span class="ruby-identifier">pattern</span> = [<span class="ruby-identifier">base_name</span>, <span class="ruby-string">"callgrind.out"</span>, <span class="ruby-identifier">$$</span>, <span class="ruby-string">"*"</span>].<span class="ruby-identifier">join</span>(<span class="ruby-string">"."</span>)
|
617
|
+
<span class="ruby-identifier">files</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">pattern</span>))
|
618
|
+
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_f</span>(<span class="ruby-identifier">files</span>)
|
619
|
+
<span class="ruby-keyword">end</span></pre>
|
620
|
+
</div>
|
621
|
+
|
622
|
+
</div>
|
623
|
+
|
624
|
+
|
625
|
+
|
626
|
+
|
345
627
|
</div>
|
346
628
|
|
347
629
|
|
@@ -353,7 +635,7 @@ and similar tools.</p>
|
|
353
635
|
|
354
636
|
<footer id="validator-badges" role="contentinfo">
|
355
637
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
356
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.
|
638
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
357
639
|
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
358
640
|
</footer>
|
359
641
|
|