ruby-prof 0.15.8 → 0.15.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +5 -0
- data/README.rdoc +187 -185
- data/doc/LICENSE.html +114 -0
- data/doc/README_rdoc.html +544 -0
- data/doc/Rack.html +95 -0
- data/doc/Rack/RubyProf.html +223 -0
- data/doc/RubyProf.html +961 -0
- data/doc/RubyProf/AbstractPrinter.html +546 -0
- data/doc/RubyProf/AggregateCallInfo.html +551 -0
- data/doc/RubyProf/CallInfo.html +639 -0
- data/doc/RubyProf/CallInfoPrinter.html +120 -0
- data/doc/RubyProf/CallInfoVisitor.html +198 -0
- data/doc/RubyProf/CallStackPrinter.html +1121 -0
- data/doc/RubyProf/CallTreePrinter.html +359 -0
- data/doc/RubyProf/Cmd.html +631 -0
- data/doc/RubyProf/DotPrinter.html +257 -0
- data/doc/RubyProf/FlatPrinter.html +163 -0
- data/doc/RubyProf/FlatPrinterWithLineNumbers.html +208 -0
- data/doc/RubyProf/GraphHtmlPrinter.html +552 -0
- data/doc/RubyProf/GraphPrinter.html +139 -0
- data/doc/RubyProf/MethodInfo.html +745 -0
- data/doc/RubyProf/MultiPrinter.html +358 -0
- data/doc/RubyProf/Profile.html +713 -0
- data/doc/RubyProf/ProfileTask.html +490 -0
- data/doc/RubyProf/Thread.html +268 -0
- data/doc/created.rid +13 -13
- data/doc/examples/flat_txt.html +138 -0
- data/doc/examples/graph_html.html +909 -0
- data/doc/examples/graph_txt.html +247 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +571 -0
- 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.gz +0 -0
- data/doc/table_of_contents.html +893 -0
- data/examples/flat.txt +50 -55
- data/examples/graph.html +823 -823
- data/examples/graph.txt +139 -170
- data/ext/ruby_prof/extconf.rb +6 -1
- data/lib/ruby-prof/aggregate_call_info.rb +17 -11
- data/lib/ruby-prof/call_info.rb +2 -17
- data/lib/ruby-prof/method_info.rb +6 -22
- data/lib/ruby-prof/printers/graph_html_printer.rb +0 -2
- data/lib/ruby-prof/printers/graph_printer.rb +4 -6
- data/lib/ruby-prof/rack.rb +7 -0
- data/lib/ruby-prof/thread.rb +0 -4
- data/lib/ruby-prof/version.rb +1 -1
- data/ruby-prof.gemspec +1 -1
- data/test/basic_test.rb +26 -26
- data/test/issue137_test.rb +63 -0
- data/test/measure_allocations_test.rb +4 -3
- data/test/measure_cpu_time_test.rb +6 -6
- data/test/measure_process_time_test.rb +8 -8
- data/test/pause_resume_test.rb +9 -9
- data/test/printers_test.rb +1 -1
- data/test/printing_recursive_graph_test.rb +127 -0
- data/test/rack_test.rb +49 -1
- data/test/recursive_test.rb +41 -37
- data/test/test_helper.rb +93 -0
- metadata +59 -5
@@ -0,0 +1,639 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class RubyProf::CallInfo - ruby-prof</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
</script>
|
12
|
+
|
13
|
+
<script src="../js/jquery.js"></script>
|
14
|
+
<script src="../js/darkfish.js"></script>
|
15
|
+
|
16
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
17
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
<body id="top" role="document" class="class">
|
22
|
+
<nav role="navigation">
|
23
|
+
<div id="project-navigation">
|
24
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
25
|
+
<h2>
|
26
|
+
<a href="../index.html" rel="home">Home</a>
|
27
|
+
</h2>
|
28
|
+
|
29
|
+
<div id="table-of-contents-navigation">
|
30
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
31
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
32
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
37
|
+
<form action="#" method="get" accept-charset="utf-8">
|
38
|
+
<div id="search-field-wrapper">
|
39
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
40
|
+
aria-autocomplete="list" aria-controls="search-results"
|
41
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
42
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<ul id="search-results" aria-label="Search Results"
|
46
|
+
aria-busy="false" aria-expanded="false"
|
47
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
48
|
+
</form>
|
49
|
+
</div>
|
50
|
+
|
51
|
+
</div>
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
<div id="class-metadata">
|
56
|
+
|
57
|
+
<div id="parent-class-section" class="nav-section">
|
58
|
+
<h3>Parent</h3>
|
59
|
+
|
60
|
+
|
61
|
+
<p class="link">Object
|
62
|
+
|
63
|
+
</div>
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
<!-- Method Quickref -->
|
68
|
+
<div id="method-list-section" class="nav-section">
|
69
|
+
<h3>Methods</h3>
|
70
|
+
|
71
|
+
<ul class="link-list" role="directory">
|
72
|
+
|
73
|
+
<li ><a href="#method-c-roots_of">::roots_of</a>
|
74
|
+
|
75
|
+
<li ><a href="#method-i-call_sequence">#call_sequence</a>
|
76
|
+
|
77
|
+
<li ><a href="#method-i-children_time">#children_time</a>
|
78
|
+
|
79
|
+
<li ><a href="#method-i-descendent_of">#descendent_of</a>
|
80
|
+
|
81
|
+
<li ><a href="#method-i-detect_recursion">#detect_recursion</a>
|
82
|
+
|
83
|
+
<li ><a href="#method-i-eliminate-21">#eliminate!</a>
|
84
|
+
|
85
|
+
<li ><a href="#method-i-find_call">#find_call</a>
|
86
|
+
|
87
|
+
<li class="calls-super" ><a href="#method-i-inspect">#inspect</a>
|
88
|
+
|
89
|
+
<li ><a href="#method-i-merge_call_tree">#merge_call_tree</a>
|
90
|
+
|
91
|
+
<li ><a href="#method-i-root-3F">#root?</a>
|
92
|
+
|
93
|
+
<li ><a href="#method-i-stack">#stack</a>
|
94
|
+
|
95
|
+
<li ><a href="#method-i-to_s">#to_s</a>
|
96
|
+
|
97
|
+
</ul>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
</nav>
|
102
|
+
|
103
|
+
<main role="main" aria-labelledby="class-RubyProf::CallInfo">
|
104
|
+
<h1 id="class-RubyProf::CallInfo" class="class">
|
105
|
+
class RubyProf::CallInfo
|
106
|
+
</h1>
|
107
|
+
|
108
|
+
<section class="description">
|
109
|
+
|
110
|
+
</section>
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<section class="attribute-method-details" class="method-section">
|
124
|
+
<header>
|
125
|
+
<h3>Attributes</h3>
|
126
|
+
</header>
|
127
|
+
|
128
|
+
|
129
|
+
<div id="attribute-i-recursive" class="method-detail">
|
130
|
+
<div class="method-heading attribute-method-heading">
|
131
|
+
<span class="method-name">recursive</span><span
|
132
|
+
class="attribute-access-type">[R]</span>
|
133
|
+
</div>
|
134
|
+
|
135
|
+
<div class="method-description">
|
136
|
+
|
137
|
+
<p>part of this class is defined in C code. it provides the following
|
138
|
+
attributes pertaining to tree structure: depth: tree level (0 == root)
|
139
|
+
parent: parent call info (can be nil) children: array of call info
|
140
|
+
children (can be empty) target: method info (containing an array of
|
141
|
+
call infos)</p>
|
142
|
+
|
143
|
+
</div>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
</section>
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
151
|
+
<header>
|
152
|
+
<h3>Public Class Methods</h3>
|
153
|
+
</header>
|
154
|
+
|
155
|
+
|
156
|
+
<div id="method-c-roots_of" class="method-detail ">
|
157
|
+
|
158
|
+
<div class="method-heading">
|
159
|
+
<span class="method-name">roots_of</span><span
|
160
|
+
class="method-args">(call_infos)</span>
|
161
|
+
|
162
|
+
<span class="method-click-advice">click to toggle source</span>
|
163
|
+
|
164
|
+
</div>
|
165
|
+
|
166
|
+
|
167
|
+
<div class="method-description">
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
<div class="method-source-code" id="roots_of-source">
|
175
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 59</span>
|
176
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">roots_of</span>(<span class="ruby-identifier">call_infos</span>)
|
177
|
+
<span class="ruby-identifier">roots</span> = []
|
178
|
+
<span class="ruby-identifier">sorted</span> = <span class="ruby-identifier">call_infos</span>.<span class="ruby-identifier">sort_by</span>(<span class="ruby-operator">&</span><span class="ruby-value">:depth</span>).<span class="ruby-identifier">reverse</span>
|
179
|
+
<span class="ruby-keyword">while</span> <span class="ruby-identifier">call_info</span> = <span class="ruby-identifier">sorted</span>.<span class="ruby-identifier">shift</span>
|
180
|
+
<span class="ruby-identifier">roots</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">call_info</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">sorted</span>.<span class="ruby-identifier">any?</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">call_info</span>.<span class="ruby-identifier">descendent_of</span>(<span class="ruby-identifier">p</span>)}
|
181
|
+
<span class="ruby-keyword">end</span>
|
182
|
+
<span class="ruby-identifier">roots</span>
|
183
|
+
<span class="ruby-keyword">end</span></pre>
|
184
|
+
</div>
|
185
|
+
|
186
|
+
</div>
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
</div>
|
192
|
+
|
193
|
+
|
194
|
+
</section>
|
195
|
+
|
196
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
197
|
+
<header>
|
198
|
+
<h3>Public Instance Methods</h3>
|
199
|
+
</header>
|
200
|
+
|
201
|
+
|
202
|
+
<div id="method-i-call_sequence" class="method-detail ">
|
203
|
+
|
204
|
+
<div class="method-heading">
|
205
|
+
<span class="method-name">call_sequence</span><span
|
206
|
+
class="method-args">()</span>
|
207
|
+
|
208
|
+
<span class="method-click-advice">click to toggle source</span>
|
209
|
+
|
210
|
+
</div>
|
211
|
+
|
212
|
+
|
213
|
+
<div class="method-description">
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
<div class="method-source-code" id="call_sequence-source">
|
221
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 41</span>
|
222
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">call_sequence</span>
|
223
|
+
<span class="ruby-ivar">@call_sequence</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">begin</span>
|
224
|
+
<span class="ruby-identifier">stack</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">full_name</span>}.<span class="ruby-identifier">join</span>(<span class="ruby-string">'->'</span>)
|
225
|
+
<span class="ruby-keyword">end</span>
|
226
|
+
<span class="ruby-keyword">end</span></pre>
|
227
|
+
</div>
|
228
|
+
|
229
|
+
</div>
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
</div>
|
235
|
+
|
236
|
+
|
237
|
+
<div id="method-i-children_time" class="method-detail ">
|
238
|
+
|
239
|
+
<div class="method-heading">
|
240
|
+
<span class="method-name">children_time</span><span
|
241
|
+
class="method-args">()</span>
|
242
|
+
|
243
|
+
<span class="method-click-advice">click to toggle source</span>
|
244
|
+
|
245
|
+
</div>
|
246
|
+
|
247
|
+
|
248
|
+
<div class="method-description">
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
<div class="method-source-code" id="children_time-source">
|
256
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 22</span>
|
257
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">children_time</span>
|
258
|
+
<span class="ruby-identifier">children</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">sum</span>, <span class="ruby-identifier">call_info</span><span class="ruby-operator">|</span>
|
259
|
+
<span class="ruby-identifier">sum</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">call_info</span>.<span class="ruby-identifier">total_time</span>
|
260
|
+
<span class="ruby-keyword">end</span>
|
261
|
+
<span class="ruby-keyword">end</span></pre>
|
262
|
+
</div>
|
263
|
+
|
264
|
+
</div>
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
</div>
|
270
|
+
|
271
|
+
|
272
|
+
<div id="method-i-descendent_of" class="method-detail ">
|
273
|
+
|
274
|
+
<div class="method-heading">
|
275
|
+
<span class="method-name">descendent_of</span><span
|
276
|
+
class="method-args">(other)</span>
|
277
|
+
|
278
|
+
<span class="method-click-advice">click to toggle source</span>
|
279
|
+
|
280
|
+
</div>
|
281
|
+
|
282
|
+
|
283
|
+
<div class="method-description">
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
<div class="method-source-code" id="descendent_of-source">
|
291
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 51</span>
|
292
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">descendent_of</span>(<span class="ruby-identifier">other</span>)
|
293
|
+
<span class="ruby-identifier">p</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">parent</span>
|
294
|
+
<span class="ruby-keyword">while</span> <span class="ruby-identifier">p</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">p</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">other</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">depth</span> <span class="ruby-operator">></span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">depth</span>
|
295
|
+
<span class="ruby-identifier">p</span> = <span class="ruby-identifier">p</span>.<span class="ruby-identifier">parent</span>
|
296
|
+
<span class="ruby-keyword">end</span>
|
297
|
+
<span class="ruby-identifier">p</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>
|
298
|
+
<span class="ruby-keyword">end</span></pre>
|
299
|
+
</div>
|
300
|
+
|
301
|
+
</div>
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
</div>
|
307
|
+
|
308
|
+
|
309
|
+
<div id="method-i-detect_recursion" class="method-detail ">
|
310
|
+
|
311
|
+
<div class="method-heading">
|
312
|
+
<span class="method-name">detect_recursion</span><span
|
313
|
+
class="method-args">(visited_methods = Hash.new(0))</span>
|
314
|
+
|
315
|
+
<span class="method-click-advice">click to toggle source</span>
|
316
|
+
|
317
|
+
</div>
|
318
|
+
|
319
|
+
|
320
|
+
<div class="method-description">
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
<div class="method-source-code" id="detect_recursion-source">
|
328
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 13</span>
|
329
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">detect_recursion</span>(<span class="ruby-identifier">visited_methods</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>))
|
330
|
+
<span class="ruby-ivar">@recursive</span> = (<span class="ruby-identifier">visited_methods</span>[<span class="ruby-identifier">target</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>) <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
331
|
+
<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">child</span><span class="ruby-operator">|</span>
|
332
|
+
<span class="ruby-identifier">child</span>.<span class="ruby-identifier">detect_recursion</span>(<span class="ruby-identifier">visited_methods</span>)
|
333
|
+
<span class="ruby-keyword">end</span>
|
334
|
+
<span class="ruby-identifier">visited_methods</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">target</span>) <span class="ruby-keyword">if</span> (<span class="ruby-identifier">visited_methods</span>[<span class="ruby-identifier">target</span>] <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
335
|
+
<span class="ruby-keyword">return</span> <span class="ruby-ivar">@recursive</span>
|
336
|
+
<span class="ruby-keyword">end</span></pre>
|
337
|
+
</div>
|
338
|
+
|
339
|
+
</div>
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
</div>
|
345
|
+
|
346
|
+
|
347
|
+
<div id="method-i-eliminate-21" class="method-detail ">
|
348
|
+
|
349
|
+
<div class="method-heading">
|
350
|
+
<span class="method-name">eliminate!</span><span
|
351
|
+
class="method-args">()</span>
|
352
|
+
|
353
|
+
<span class="method-click-advice">click to toggle source</span>
|
354
|
+
|
355
|
+
</div>
|
356
|
+
|
357
|
+
|
358
|
+
<div class="method-description">
|
359
|
+
|
360
|
+
<p>eliminate call info from the call tree. adds self and wait time to parent
|
361
|
+
and attaches called methods to parent. merges call trees for methods called
|
362
|
+
from both praent end self.</p>
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
<div class="method-source-code" id="eliminate-21-source">
|
368
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 79</span>
|
369
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">eliminate!</span>
|
370
|
+
<span class="ruby-comment"># puts "eliminating #{self}"</span>
|
371
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">parent</span>
|
372
|
+
<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">add_self_time</span>(<span class="ruby-keyword">self</span>)
|
373
|
+
<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">add_wait_time</span>(<span class="ruby-keyword">self</span>)
|
374
|
+
<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">kid</span><span class="ruby-operator">|</span>
|
375
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">call</span> = <span class="ruby-identifier">parent</span>.<span class="ruby-identifier">find_call</span>(<span class="ruby-identifier">kid</span>)
|
376
|
+
<span class="ruby-identifier">call</span>.<span class="ruby-identifier">merge_call_tree</span>(<span class="ruby-identifier">kid</span>)
|
377
|
+
<span class="ruby-keyword">else</span>
|
378
|
+
<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">children</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">kid</span>
|
379
|
+
<span class="ruby-comment"># $stderr.puts "setting parent of #{kid}\nto #{parent}"</span>
|
380
|
+
<span class="ruby-identifier">kid</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-identifier">parent</span>
|
381
|
+
<span class="ruby-keyword">end</span>
|
382
|
+
<span class="ruby-keyword">end</span>
|
383
|
+
<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-keyword">self</span>)
|
384
|
+
<span class="ruby-keyword">end</span></pre>
|
385
|
+
</div>
|
386
|
+
|
387
|
+
</div>
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
</div>
|
393
|
+
|
394
|
+
|
395
|
+
<div id="method-i-find_call" class="method-detail ">
|
396
|
+
|
397
|
+
<div class="method-heading">
|
398
|
+
<span class="method-name">find_call</span><span
|
399
|
+
class="method-args">(other)</span>
|
400
|
+
|
401
|
+
<span class="method-click-advice">click to toggle source</span>
|
402
|
+
|
403
|
+
</div>
|
404
|
+
|
405
|
+
|
406
|
+
<div class="method-description">
|
407
|
+
|
408
|
+
<p>find a specific call in list of children. returns nil if not found. note:
|
409
|
+
there can't be more than one child with a given target method. in other
|
410
|
+
words: x.children.grep{|y|y.target==m}.size <= 1 for all method infos m
|
411
|
+
and call infos x</p>
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
<div class="method-source-code" id="find_call-source">
|
417
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 99</span>
|
418
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">find_call</span>(<span class="ruby-identifier">other</span>)
|
419
|
+
<span class="ruby-identifier">matching</span> = <span class="ruby-identifier">children</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">kid</span><span class="ruby-operator">|</span> <span class="ruby-identifier">kid</span>.<span class="ruby-identifier">target</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">target</span> }
|
420
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-string">"inconsistent call tree"</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">matching</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator"><=</span> <span class="ruby-value">1</span>
|
421
|
+
<span class="ruby-identifier">matching</span>.<span class="ruby-identifier">first</span>
|
422
|
+
<span class="ruby-keyword">end</span></pre>
|
423
|
+
</div>
|
424
|
+
|
425
|
+
</div>
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
</div>
|
431
|
+
|
432
|
+
|
433
|
+
<div id="method-i-inspect" class="method-detail ">
|
434
|
+
|
435
|
+
<div class="method-heading">
|
436
|
+
<span class="method-name">inspect</span><span
|
437
|
+
class="method-args">()</span>
|
438
|
+
|
439
|
+
<span class="method-click-advice">click to toggle source</span>
|
440
|
+
|
441
|
+
</div>
|
442
|
+
|
443
|
+
|
444
|
+
<div class="method-description">
|
445
|
+
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
<div class="method-calls-super">
|
450
|
+
Calls superclass method
|
451
|
+
|
452
|
+
</div>
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
<div class="method-source-code" id="inspect-source">
|
457
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 72</span>
|
458
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">inspect</span>
|
459
|
+
<span class="ruby-keyword">super</span> <span class="ruby-operator">+</span> <span class="ruby-node">"(#{target.full_name}, d: #{depth}, c: #{called}, tt: #{total_time}, st: #{self_time}, ct: #{children_time})"</span>
|
460
|
+
<span class="ruby-keyword">end</span></pre>
|
461
|
+
</div>
|
462
|
+
|
463
|
+
</div>
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
</div>
|
469
|
+
|
470
|
+
|
471
|
+
<div id="method-i-merge_call_tree" class="method-detail ">
|
472
|
+
|
473
|
+
<div class="method-heading">
|
474
|
+
<span class="method-name">merge_call_tree</span><span
|
475
|
+
class="method-args">(other)</span>
|
476
|
+
|
477
|
+
<span class="method-click-advice">click to toggle source</span>
|
478
|
+
|
479
|
+
</div>
|
480
|
+
|
481
|
+
|
482
|
+
<div class="method-description">
|
483
|
+
|
484
|
+
<p>merge two call trees. adds self, wait, and total time of other to self and
|
485
|
+
merges children of other into children of self.</p>
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
|
490
|
+
<div class="method-source-code" id="merge_call_tree-source">
|
491
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 106</span>
|
492
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">merge_call_tree</span>(<span class="ruby-identifier">other</span>)
|
493
|
+
<span class="ruby-comment"># $stderr.puts "merging #{self}\nand #{other}"</span>
|
494
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">called</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">called</span>
|
495
|
+
<span class="ruby-identifier">add_self_time</span>(<span class="ruby-identifier">other</span>)
|
496
|
+
<span class="ruby-identifier">add_wait_time</span>(<span class="ruby-identifier">other</span>)
|
497
|
+
<span class="ruby-identifier">add_total_time</span>(<span class="ruby-identifier">other</span>)
|
498
|
+
<span class="ruby-identifier">other</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">other_kid</span><span class="ruby-operator">|</span>
|
499
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">kid</span> = <span class="ruby-identifier">find_call</span>(<span class="ruby-identifier">other_kid</span>)
|
500
|
+
<span class="ruby-comment"># $stderr.puts "merging kids"</span>
|
501
|
+
<span class="ruby-identifier">kid</span>.<span class="ruby-identifier">merge_call_tree</span>(<span class="ruby-identifier">other_kid</span>)
|
502
|
+
<span class="ruby-keyword">else</span>
|
503
|
+
<span class="ruby-identifier">other_kid</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-keyword">self</span>
|
504
|
+
<span class="ruby-identifier">children</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">other_kid</span>
|
505
|
+
<span class="ruby-keyword">end</span>
|
506
|
+
<span class="ruby-keyword">end</span>
|
507
|
+
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">children</span>.<span class="ruby-identifier">clear</span>
|
508
|
+
<span class="ruby-identifier">other</span>.<span class="ruby-identifier">target</span>.<span class="ruby-identifier">call_infos</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">other</span>)
|
509
|
+
<span class="ruby-keyword">end</span></pre>
|
510
|
+
</div>
|
511
|
+
|
512
|
+
</div>
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
</div>
|
518
|
+
|
519
|
+
|
520
|
+
<div id="method-i-root-3F" class="method-detail ">
|
521
|
+
|
522
|
+
<div class="method-heading">
|
523
|
+
<span class="method-name">root?</span><span
|
524
|
+
class="method-args">()</span>
|
525
|
+
|
526
|
+
<span class="method-click-advice">click to toggle source</span>
|
527
|
+
|
528
|
+
</div>
|
529
|
+
|
530
|
+
|
531
|
+
<div class="method-description">
|
532
|
+
|
533
|
+
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
|
538
|
+
<div class="method-source-code" id="root-3F-source">
|
539
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 47</span>
|
540
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">root?</span>
|
541
|
+
<span class="ruby-keyword">self</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">nil?</span>
|
542
|
+
<span class="ruby-keyword">end</span></pre>
|
543
|
+
</div>
|
544
|
+
|
545
|
+
</div>
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
</div>
|
551
|
+
|
552
|
+
|
553
|
+
<div id="method-i-stack" class="method-detail ">
|
554
|
+
|
555
|
+
<div class="method-heading">
|
556
|
+
<span class="method-name">stack</span><span
|
557
|
+
class="method-args">()</span>
|
558
|
+
|
559
|
+
<span class="method-click-advice">click to toggle source</span>
|
560
|
+
|
561
|
+
</div>
|
562
|
+
|
563
|
+
|
564
|
+
<div class="method-description">
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
<div class="method-source-code" id="stack-source">
|
572
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 28</span>
|
573
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">stack</span>
|
574
|
+
<span class="ruby-ivar">@stack</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">begin</span>
|
575
|
+
<span class="ruby-identifier">methods</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
|
576
|
+
<span class="ruby-identifier">call_info</span> = <span class="ruby-keyword">self</span>
|
577
|
+
|
578
|
+
<span class="ruby-keyword">while</span> <span class="ruby-identifier">call_info</span>
|
579
|
+
<span class="ruby-identifier">methods</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">call_info</span>.<span class="ruby-identifier">target</span>
|
580
|
+
<span class="ruby-identifier">call_info</span> = <span class="ruby-identifier">call_info</span>.<span class="ruby-identifier">parent</span>
|
581
|
+
<span class="ruby-keyword">end</span>
|
582
|
+
<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">reverse</span>
|
583
|
+
<span class="ruby-keyword">end</span>
|
584
|
+
<span class="ruby-keyword">end</span></pre>
|
585
|
+
</div>
|
586
|
+
|
587
|
+
</div>
|
588
|
+
|
589
|
+
|
590
|
+
|
591
|
+
|
592
|
+
</div>
|
593
|
+
|
594
|
+
|
595
|
+
<div id="method-i-to_s" class="method-detail ">
|
596
|
+
|
597
|
+
<div class="method-heading">
|
598
|
+
<span class="method-name">to_s</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="to_s-source">
|
614
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/call_info.rb, line 68</span>
|
615
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_s</span>
|
616
|
+
<span class="ruby-node">"#{target.full_name} (c: #{called}, tt: #{total_time}, st: #{self_time}, ct: #{children_time})"</span>
|
617
|
+
<span class="ruby-keyword">end</span></pre>
|
618
|
+
</div>
|
619
|
+
|
620
|
+
</div>
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
|
625
|
+
</div>
|
626
|
+
|
627
|
+
|
628
|
+
</section>
|
629
|
+
|
630
|
+
</section>
|
631
|
+
</main>
|
632
|
+
|
633
|
+
|
634
|
+
<footer id="validator-badges" role="contentinfo">
|
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.0.
|
637
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
638
|
+
</footer>
|
639
|
+
|