ruby-prof 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +9 -0
  3. data/README.rdoc +24 -39
  4. data/bin/ruby-prof +1 -2
  5. data/doc/created.rid +8 -8
  6. data/doc/js/search_index.js +1 -1
  7. data/doc/js/search_index.js.gz +0 -0
  8. data/ext/ruby_prof/rp_measure.c +20 -28
  9. data/ext/ruby_prof/rp_measure.h +6 -6
  10. data/ext/ruby_prof/rp_measure_allocations.c +9 -2
  11. data/ext/ruby_prof/rp_measure_memory.c +4 -0
  12. data/lib/ruby-prof.rb +9 -20
  13. data/lib/ruby-prof/compatibility.rb +12 -4
  14. data/lib/ruby-prof/printers/flat_printer.rb +1 -0
  15. data/lib/ruby-prof/version.rb +1 -1
  16. data/test/thread_test.rb +7 -4
  17. metadata +2 -54
  18. data/doc/LICENSE.html +0 -114
  19. data/doc/README_rdoc.html +0 -607
  20. data/doc/Rack.html +0 -95
  21. data/doc/Rack/RubyProf.html +0 -264
  22. data/doc/RubyProf.html +0 -965
  23. data/doc/RubyProf/AbstractPrinter.html +0 -546
  24. data/doc/RubyProf/AggregateCallInfo.html +0 -537
  25. data/doc/RubyProf/CallInfo.html +0 -468
  26. data/doc/RubyProf/CallInfoPrinter.html +0 -120
  27. data/doc/RubyProf/CallInfoVisitor.html +0 -200
  28. data/doc/RubyProf/CallStackPrinter.html +0 -1604
  29. data/doc/RubyProf/CallTreePrinter.html +0 -359
  30. data/doc/RubyProf/Cmd.html +0 -624
  31. data/doc/RubyProf/DotPrinter.html +0 -257
  32. data/doc/RubyProf/FlatPrinter.html +0 -163
  33. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +0 -201
  34. data/doc/RubyProf/GraphHtmlPrinter.html +0 -575
  35. data/doc/RubyProf/GraphPrinter.html +0 -139
  36. data/doc/RubyProf/MethodInfo.html +0 -685
  37. data/doc/RubyProf/MultiPrinter.html +0 -358
  38. data/doc/RubyProf/Profile.html +0 -764
  39. data/doc/RubyProf/ProfileTask.html +0 -490
  40. data/doc/RubyProf/Thread.html +0 -199
  41. data/doc/examples/flat_txt.html +0 -149
  42. data/doc/examples/graph_html.html +0 -850
  43. data/doc/examples/graph_txt.html +0 -274
  44. data/doc/images/add.png +0 -0
  45. data/doc/images/arrow_up.png +0 -0
  46. data/doc/images/brick.png +0 -0
  47. data/doc/images/brick_link.png +0 -0
  48. data/doc/images/bug.png +0 -0
  49. data/doc/images/bullet_black.png +0 -0
  50. data/doc/images/bullet_toggle_minus.png +0 -0
  51. data/doc/images/bullet_toggle_plus.png +0 -0
  52. data/doc/images/date.png +0 -0
  53. data/doc/images/delete.png +0 -0
  54. data/doc/images/find.png +0 -0
  55. data/doc/images/macFFBgHack.png +0 -0
  56. data/doc/images/package.png +0 -0
  57. data/doc/images/page_green.png +0 -0
  58. data/doc/images/page_white_text.png +0 -0
  59. data/doc/images/page_white_width.png +0 -0
  60. data/doc/images/plugin.png +0 -0
  61. data/doc/images/ruby.png +0 -0
  62. data/doc/images/tag_blue.png +0 -0
  63. data/doc/images/tag_green.png +0 -0
  64. data/doc/images/transparent.png +0 -0
  65. data/doc/images/wrench.png +0 -0
  66. data/doc/images/wrench_orange.png +0 -0
  67. data/doc/images/zoom.png +0 -0
  68. data/doc/index.html +0 -633
  69. data/doc/table_of_contents.html +0 -859
@@ -1,358 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class RubyProf::MultiPrinter - 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-new">::new</a>
74
-
75
- <li ><a href="#method-i-flat_profile">#flat_profile</a>
76
-
77
- <li ><a href="#method-i-graph_profile">#graph_profile</a>
78
-
79
- <li ><a href="#method-i-print">#print</a>
80
-
81
- <li ><a href="#method-i-stack_profile">#stack_profile</a>
82
-
83
- <li ><a href="#method-i-tree_profile">#tree_profile</a>
84
-
85
- </ul>
86
- </div>
87
-
88
- </div>
89
- </nav>
90
-
91
- <main role="main" aria-labelledby="class-RubyProf::MultiPrinter">
92
- <h1 id="class-RubyProf::MultiPrinter" class="class">
93
- class RubyProf::MultiPrinter
94
- </h1>
95
-
96
- <section class="description">
97
-
98
- <p>Helper class to simplify printing profiles of several types from one
99
- profiling run. Currently prints a flat profile, a callgrind profile, a call
100
- stack profile and a graph profile.</p>
101
-
102
- </section>
103
-
104
-
105
-
106
-
107
- <section id="5Buntitled-5D" class="documentation-section">
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
118
- <header>
119
- <h3>Public Class Methods</h3>
120
- </header>
121
-
122
-
123
- <div id="method-c-new" class="method-detail ">
124
-
125
- <div class="method-heading">
126
- <span class="method-name">new</span><span
127
- class="method-args">(result)</span>
128
-
129
- <span class="method-click-advice">click to toggle source</span>
130
-
131
- </div>
132
-
133
-
134
- <div class="method-description">
135
-
136
-
137
-
138
-
139
-
140
-
141
- <div class="method-source-code" id="new-source">
142
- <pre><span class="ruby-comment"># File lib/ruby-prof/printers/multi_printer.rb, line 7</span>
143
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">result</span>)
144
- <span class="ruby-ivar">@stack_printer</span> = <span class="ruby-constant">CallStackPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
145
- <span class="ruby-ivar">@graph_printer</span> = <span class="ruby-constant">GraphHtmlPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
146
- <span class="ruby-ivar">@tree_printer</span> = <span class="ruby-constant">CallTreePrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
147
- <span class="ruby-ivar">@flat_printer</span> = <span class="ruby-constant">FlatPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
148
- <span class="ruby-keyword">end</span></pre>
149
- </div>
150
-
151
- </div>
152
-
153
-
154
-
155
-
156
- </div>
157
-
158
-
159
- </section>
160
-
161
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
162
- <header>
163
- <h3>Public Instance Methods</h3>
164
- </header>
165
-
166
-
167
- <div id="method-i-flat_profile" class="method-detail ">
168
-
169
- <div class="method-heading">
170
- <span class="method-name">flat_profile</span><span
171
- class="method-args">()</span>
172
-
173
- <span class="method-click-advice">click to toggle source</span>
174
-
175
- </div>
176
-
177
-
178
- <div class="method-description">
179
-
180
- <p>the name of the flat profile file</p>
181
-
182
-
183
-
184
-
185
- <div class="method-source-code" id="flat_profile-source">
186
- <pre><span class="ruby-comment"># File lib/ruby-prof/printers/multi_printer.rb, line 50</span>
187
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">flat_profile</span>
188
- <span class="ruby-node">&quot;#{@directory}/#{@profile}.flat.txt&quot;</span>
189
- <span class="ruby-keyword">end</span></pre>
190
- </div>
191
-
192
- </div>
193
-
194
-
195
-
196
-
197
- </div>
198
-
199
-
200
- <div id="method-i-graph_profile" class="method-detail ">
201
-
202
- <div class="method-heading">
203
- <span class="method-name">graph_profile</span><span
204
- class="method-args">()</span>
205
-
206
- <span class="method-click-advice">click to toggle source</span>
207
-
208
- </div>
209
-
210
-
211
- <div class="method-description">
212
-
213
- <p>the name of the graph profile file</p>
214
-
215
-
216
-
217
-
218
- <div class="method-source-code" id="graph_profile-source">
219
- <pre><span class="ruby-comment"># File lib/ruby-prof/printers/multi_printer.rb, line 40</span>
220
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">graph_profile</span>
221
- <span class="ruby-node">&quot;#{@directory}/#{@profile}.graph.html&quot;</span>
222
- <span class="ruby-keyword">end</span></pre>
223
- </div>
224
-
225
- </div>
226
-
227
-
228
-
229
-
230
- </div>
231
-
232
-
233
- <div id="method-i-print" class="method-detail ">
234
-
235
- <div class="method-heading">
236
- <span class="method-name">print</span><span
237
- class="method-args">(options)</span>
238
-
239
- <span class="method-click-advice">click to toggle source</span>
240
-
241
- </div>
242
-
243
-
244
- <div class="method-description">
245
-
246
- <p>create profile files under <a href=":path">options</a> or the current
247
- directory. <a href=":profile">options</a> is used as the base name for the
248
- pofile file, defaults to “profile”.</p>
249
-
250
-
251
-
252
-
253
- <div class="method-source-code" id="print-source">
254
- <pre><span class="ruby-comment"># File lib/ruby-prof/printers/multi_printer.rb, line 17</span>
255
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">print</span>(<span class="ruby-identifier">options</span>)
256
- <span class="ruby-ivar">@profile</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:profile</span>) <span class="ruby-operator">||</span> <span class="ruby-string">&quot;profile&quot;</span>
257
- <span class="ruby-ivar">@directory</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:path</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-string">&quot;.&quot;</span>)
258
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">stack_profile</span>, <span class="ruby-string">&quot;w&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
259
- <span class="ruby-ivar">@stack_printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value">:graph</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{@profile}.graph.html&quot;</span>))
260
- <span class="ruby-keyword">end</span>
261
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">graph_profile</span>, <span class="ruby-string">&quot;w&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
262
- <span class="ruby-ivar">@graph_printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">options</span>)
263
- <span class="ruby-keyword">end</span>
264
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">tree_profile</span>, <span class="ruby-string">&quot;w&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
265
- <span class="ruby-ivar">@tree_printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">options</span>)
266
- <span class="ruby-keyword">end</span>
267
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">flat_profile</span>, <span class="ruby-string">&quot;w&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
268
- <span class="ruby-ivar">@flat_printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">options</span>)
269
- <span class="ruby-keyword">end</span>
270
- <span class="ruby-keyword">end</span></pre>
271
- </div>
272
-
273
- </div>
274
-
275
-
276
-
277
-
278
- </div>
279
-
280
-
281
- <div id="method-i-stack_profile" class="method-detail ">
282
-
283
- <div class="method-heading">
284
- <span class="method-name">stack_profile</span><span
285
- class="method-args">()</span>
286
-
287
- <span class="method-click-advice">click to toggle source</span>
288
-
289
- </div>
290
-
291
-
292
- <div class="method-description">
293
-
294
- <p>the name of the call stack profile file</p>
295
-
296
-
297
-
298
-
299
- <div class="method-source-code" id="stack_profile-source">
300
- <pre><span class="ruby-comment"># File lib/ruby-prof/printers/multi_printer.rb, line 35</span>
301
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">stack_profile</span>
302
- <span class="ruby-node">&quot;#{@directory}/#{@profile}.stack.html&quot;</span>
303
- <span class="ruby-keyword">end</span></pre>
304
- </div>
305
-
306
- </div>
307
-
308
-
309
-
310
-
311
- </div>
312
-
313
-
314
- <div id="method-i-tree_profile" class="method-detail ">
315
-
316
- <div class="method-heading">
317
- <span class="method-name">tree_profile</span><span
318
- class="method-args">()</span>
319
-
320
- <span class="method-click-advice">click to toggle source</span>
321
-
322
- </div>
323
-
324
-
325
- <div class="method-description">
326
-
327
- <p>the name of the callgrind profile file</p>
328
-
329
-
330
-
331
-
332
- <div class="method-source-code" id="tree_profile-source">
333
- <pre><span class="ruby-comment"># File lib/ruby-prof/printers/multi_printer.rb, line 45</span>
334
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">tree_profile</span>
335
- <span class="ruby-node">&quot;#{@directory}/#{@profile}.grind.dat&quot;</span>
336
- <span class="ruby-keyword">end</span></pre>
337
- </div>
338
-
339
- </div>
340
-
341
-
342
-
343
-
344
- </div>
345
-
346
-
347
- </section>
348
-
349
- </section>
350
- </main>
351
-
352
-
353
- <footer id="validator-badges" role="contentinfo">
354
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
355
- <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
356
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
357
- </footer>
358
-
@@ -1,764 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class RubyProf::Profile - 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-new">::new</a>
74
-
75
- <li ><a href="#method-c-profile">::profile</a>
76
-
77
- <li ><a href="#method-i-detect_recursion">#detect_recursion</a>
78
-
79
- <li ><a href="#method-i-eliminate_methods-21">#eliminate_methods!</a>
80
-
81
- <li ><a href="#method-i-pause">#pause</a>
82
-
83
- <li ><a href="#method-i-paused-3F">#paused?</a>
84
-
85
- <li ><a href="#method-i-post_process">#post_process</a>
86
-
87
- <li ><a href="#method-i-resume">#resume</a>
88
-
89
- <li ><a href="#method-i-running-3F">#running?</a>
90
-
91
- <li ><a href="#method-i-start">#start</a>
92
-
93
- <li ><a href="#method-i-stop">#stop</a>
94
-
95
- <li ><a href="#method-i-threads">#threads</a>
96
-
97
- </ul>
98
- </div>
99
-
100
- </div>
101
- </nav>
102
-
103
- <main role="main" aria-labelledby="class-RubyProf::Profile">
104
- <h1 id="class-RubyProf::Profile" class="class">
105
- class RubyProf::Profile
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
-
124
-
125
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
126
- <header>
127
- <h3>Public Class Methods</h3>
128
- </header>
129
-
130
-
131
- <div id="method-c-new" class="method-detail ">
132
-
133
-
134
- <div class="method-heading">
135
- <span class="method-callseq">
136
- RubyProf::Profile.new(mode, exclude_threads) &rarr; instance
137
- </span>
138
-
139
- <span class="method-click-advice">click to toggle source</span>
140
-
141
- </div>
142
-
143
-
144
-
145
- <div class="method-description">
146
-
147
- <p>Returns a new profiler.</p>
148
-
149
- <h2 id="method-c-new-label-Parameters">Parameters<span><a href="#method-c-new-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h2>
150
- <dl class="rdoc-list note-list"><dt>mode
151
- <dd>
152
- <p>Measure mode (optional). Specifies the profile measure mode. If not
153
- specified, defaults to RubyProf::WALL_TIME.</p>
154
- </dd><dt>exclude_threads
155
- <dd>
156
- <p>Threads to exclude from the profiling results (optional).</p>
157
- </dd></dl>
158
-
159
-
160
-
161
-
162
- <div class="method-source-code" id="new-source">
163
- <pre>static VALUE
164
- prof_initialize(int argc, VALUE *argv, VALUE self)
165
- {
166
- prof_profile_t* profile = prof_get_profile(self);
167
- VALUE mode;
168
- prof_measure_mode_t measurer = MEASURE_WALL_TIME;
169
- VALUE exclude_threads;
170
- int i;
171
-
172
- switch (rb_scan_args(argc, argv, &quot;02&quot;, &amp;mode, &amp;exclude_threads))
173
- {
174
- case 0:
175
- {
176
- measurer = MEASURE_WALL_TIME;
177
- exclude_threads = rb_ary_new();
178
- break;
179
- }
180
- case 1:
181
- {
182
- measurer = (prof_measure_mode_t)NUM2INT(mode);
183
- exclude_threads = rb_ary_new();
184
- break;
185
- }
186
- case 2:
187
- {
188
- Check_Type(exclude_threads, T_ARRAY);
189
- measurer = (prof_measure_mode_t)NUM2INT(mode);
190
- break;
191
- }
192
- }
193
-
194
- profile-&gt;measurer = prof_get_measurer(measurer);
195
-
196
- for (i = 0; i &lt; RARRAY_LEN(exclude_threads); i++)
197
- {
198
- VALUE thread = rb_ary_entry(exclude_threads, i);
199
- VALUE thread_id = rb_obj_id(thread);
200
- st_insert(profile-&gt;exclude_threads_tbl, thread_id, Qtrue);
201
- }
202
-
203
- return self;
204
- }</pre>
205
- </div>
206
-
207
- </div>
208
-
209
-
210
-
211
-
212
- </div>
213
-
214
-
215
- <div id="method-c-profile" class="method-detail ">
216
-
217
-
218
- <div class="method-heading">
219
- <span class="method-callseq">
220
- profile {block} &rarr; RubyProf::Result
221
- </span>
222
-
223
- <span class="method-click-advice">click to toggle source</span>
224
-
225
- </div>
226
-
227
-
228
-
229
- <div class="method-description">
230
-
231
- <p>Profiles the specified block and returns a RubyProf::Result object.</p>
232
-
233
-
234
-
235
-
236
- <div class="method-source-code" id="profile-source">
237
- <pre>static VALUE
238
- prof_profile(int argc, VALUE *argv, VALUE klass)
239
- {
240
- int result;
241
- VALUE profile = rb_class_new_instance(argc, argv, cProfile);
242
-
243
- if (!rb_block_given_p())
244
- {
245
- rb_raise(rb_eArgError, &quot;A block must be provided to the profile method.&quot;);
246
- }
247
-
248
- prof_start(profile);
249
- rb_protect(rb_yield, profile, &amp;result);
250
- return prof_stop(profile);
251
- }</pre>
252
- </div>
253
-
254
- </div>
255
-
256
-
257
-
258
-
259
- </div>
260
-
261
-
262
- </section>
263
-
264
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
265
- <header>
266
- <h3>Public Instance Methods</h3>
267
- </header>
268
-
269
-
270
- <div id="method-i-detect_recursion" class="method-detail ">
271
-
272
- <div class="method-heading">
273
- <span class="method-name">detect_recursion</span><span
274
- class="method-args">(thread)</span>
275
-
276
- <span class="method-click-advice">click to toggle source</span>
277
-
278
- </div>
279
-
280
-
281
- <div class="method-description">
282
-
283
- <p>This method detect recursive calls in the call graph.</p>
284
-
285
-
286
-
287
-
288
- <div class="method-source-code" id="detect_recursion-source">
289
- <pre><span class="ruby-comment"># File lib/ruby-prof/profile.rb, line 15</span>
290
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">detect_recursion</span>(<span class="ruby-identifier">thread</span>)
291
- <span class="ruby-identifier">visited_methods</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">hash</span>, <span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
292
- <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-value">0</span>
293
- <span class="ruby-keyword">end</span>
294
-
295
- <span class="ruby-identifier">visitor</span> = <span class="ruby-constant">CallInfoVisitor</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">thread</span>)
296
- <span class="ruby-identifier">visitor</span>.<span class="ruby-identifier">visit</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">call_info</span>, <span class="ruby-identifier">event</span><span class="ruby-operator">|</span>
297
- <span class="ruby-keyword">case</span> <span class="ruby-identifier">event</span>
298
- <span class="ruby-keyword">when</span> <span class="ruby-value">:enter</span>
299
- <span class="ruby-keyword">if</span> (<span class="ruby-identifier">visited_methods</span>[<span class="ruby-identifier">call_info</span>.<span class="ruby-identifier">target</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>) <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
300
- <span class="ruby-identifier">call_info</span>.<span class="ruby-identifier">recursive</span> = <span class="ruby-keyword">true</span>
301
- <span class="ruby-keyword">end</span>
302
- <span class="ruby-keyword">when</span> <span class="ruby-value">:exit</span>
303
- <span class="ruby-keyword">if</span> (<span class="ruby-identifier">visited_methods</span>[<span class="ruby-identifier">call_info</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>
304
- <span class="ruby-identifier">visited_methods</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">call_info</span>.<span class="ruby-identifier">target</span>)
305
- <span class="ruby-keyword">end</span>
306
- <span class="ruby-keyword">end</span>
307
- <span class="ruby-keyword">end</span>
308
- <span class="ruby-keyword">end</span></pre>
309
- </div>
310
-
311
- </div>
312
-
313
-
314
-
315
-
316
- </div>
317
-
318
-
319
- <div id="method-i-eliminate_methods-21" class="method-detail ">
320
-
321
- <div class="method-heading">
322
- <span class="method-name">eliminate_methods!</span><span
323
- class="method-args">(matchers)</span>
324
-
325
- <span class="method-click-advice">click to toggle source</span>
326
-
327
- </div>
328
-
329
-
330
- <div class="method-description">
331
-
332
- <p>eliminate some calls from the graph by merging the information into
333
- callers. matchers can be a list of strings or regular expressions or the
334
- name of a file containing regexps.</p>
335
-
336
-
337
-
338
-
339
- <div class="method-source-code" id="eliminate_methods-21-source">
340
- <pre><span class="ruby-comment"># File lib/ruby-prof/profile.rb, line 37</span>
341
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">eliminate_methods!</span>(<span class="ruby-identifier">matchers</span>)
342
- <span class="ruby-identifier">matchers</span> = <span class="ruby-identifier">read_regexps_from_file</span>(<span class="ruby-identifier">matchers</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">matchers</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
343
- <span class="ruby-identifier">eliminated</span> = []
344
- <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>
345
- <span class="ruby-identifier">matchers</span>.<span class="ruby-identifier">each</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">matcher</span><span class="ruby-operator">|</span> <span class="ruby-identifier">eliminated</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">eliminate_methods</span>(<span class="ruby-identifier">thread</span>.<span class="ruby-identifier">methods</span>, <span class="ruby-identifier">matcher</span>)) }
346
- <span class="ruby-keyword">end</span>
347
- <span class="ruby-identifier">eliminated</span>
348
- <span class="ruby-keyword">end</span></pre>
349
- </div>
350
-
351
- </div>
352
-
353
-
354
-
355
-
356
- </div>
357
-
358
-
359
- <div id="method-i-pause" class="method-detail ">
360
-
361
-
362
- <div class="method-heading">
363
- <span class="method-callseq">
364
- pause &rarr; RubyProf
365
- </span>
366
-
367
- <span class="method-click-advice">click to toggle source</span>
368
-
369
- </div>
370
-
371
-
372
-
373
- <div class="method-description">
374
-
375
- <p>Pauses collecting profile data.</p>
376
-
377
-
378
-
379
-
380
- <div class="method-source-code" id="pause-source">
381
- <pre>static VALUE
382
- prof_pause(VALUE self)
383
- {
384
- prof_profile_t* profile = prof_get_profile(self);
385
- if (profile-&gt;running == Qfalse)
386
- {
387
- rb_raise(rb_eRuntimeError, &quot;RubyProf is not running.&quot;);
388
- }
389
-
390
- if (profile-&gt;paused == Qfalse)
391
- {
392
- profile-&gt;paused = Qtrue;
393
- profile-&gt;measurement_at_pause_resume = profile-&gt;measurer-&gt;measure();
394
- st_foreach(profile-&gt;threads_tbl, pause_thread, (st_data_t) profile);
395
- }
396
-
397
- return self;
398
- }</pre>
399
- </div>
400
-
401
- </div>
402
-
403
-
404
-
405
-
406
- </div>
407
-
408
-
409
- <div id="method-i-paused-3F" class="method-detail ">
410
-
411
-
412
- <div class="method-heading">
413
- <span class="method-callseq">
414
- paused? &rarr; boolean
415
- </span>
416
-
417
- <span class="method-click-advice">click to toggle source</span>
418
-
419
- </div>
420
-
421
-
422
-
423
- <div class="method-description">
424
-
425
- <p>Returns whether a profile is currently paused.</p>
426
-
427
-
428
-
429
-
430
- <div class="method-source-code" id="paused-3F-source">
431
- <pre>static VALUE
432
- prof_paused(VALUE self)
433
- {
434
- prof_profile_t* profile = prof_get_profile(self);
435
- return profile-&gt;paused;
436
- }</pre>
437
- </div>
438
-
439
- </div>
440
-
441
-
442
-
443
-
444
- </div>
445
-
446
-
447
- <div id="method-i-post_process" class="method-detail ">
448
-
449
- <div class="method-heading">
450
- <span class="method-name">post_process</span><span
451
- class="method-args">()</span>
452
-
453
- <span class="method-click-advice">click to toggle source</span>
454
-
455
- </div>
456
-
457
-
458
- <div class="method-description">
459
-
460
- <p>This method gets called once profiling has been completed but before
461
- results are returned to the user. Thus it provides a hook to do any
462
- necessary post-processing on the call graph.</p>
463
-
464
-
465
-
466
-
467
- <div class="method-source-code" id="post_process-source">
468
- <pre><span class="ruby-comment"># File lib/ruby-prof/profile.rb, line 8</span>
469
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">post_process</span>
470
- <span class="ruby-keyword">self</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>
471
- <span class="ruby-identifier">detect_recursion</span>(<span class="ruby-identifier">thread</span>)
472
- <span class="ruby-keyword">end</span>
473
- <span class="ruby-keyword">end</span></pre>
474
- </div>
475
-
476
- </div>
477
-
478
-
479
-
480
-
481
- </div>
482
-
483
-
484
- <div id="method-i-resume" class="method-detail ">
485
-
486
-
487
- <div class="method-heading">
488
- <span class="method-callseq">
489
- resume {block} &rarr; RubyProf
490
- </span>
491
-
492
- <span class="method-click-advice">click to toggle source</span>
493
-
494
- </div>
495
-
496
-
497
-
498
- <div class="method-description">
499
-
500
- <p>Resumes recording profile data.</p>
501
-
502
-
503
-
504
-
505
- <div class="method-source-code" id="resume-source">
506
- <pre>static VALUE
507
- prof_resume(VALUE self)
508
- {
509
- prof_profile_t* profile = prof_get_profile(self);
510
- if (profile-&gt;running == Qfalse)
511
- {
512
- rb_raise(rb_eRuntimeError, &quot;RubyProf is not running.&quot;);
513
- }
514
-
515
- if (profile-&gt;paused == Qtrue)
516
- {
517
- profile-&gt;paused = Qfalse;
518
- profile-&gt;measurement_at_pause_resume = profile-&gt;measurer-&gt;measure();
519
- st_foreach(profile-&gt;threads_tbl, unpause_thread, (st_data_t) profile);
520
- }
521
-
522
- return rb_block_given_p() ? rb_ensure(rb_yield, self, prof_pause, self) : self;
523
- }</pre>
524
- </div>
525
-
526
- </div>
527
-
528
-
529
-
530
-
531
- </div>
532
-
533
-
534
- <div id="method-i-running-3F" class="method-detail ">
535
-
536
-
537
- <div class="method-heading">
538
- <span class="method-callseq">
539
- running? &rarr; boolean
540
- </span>
541
-
542
- <span class="method-click-advice">click to toggle source</span>
543
-
544
- </div>
545
-
546
-
547
-
548
- <div class="method-description">
549
-
550
- <p>Returns whether a profile is currently running.</p>
551
-
552
-
553
-
554
-
555
- <div class="method-source-code" id="running-3F-source">
556
- <pre>static VALUE
557
- prof_running(VALUE self)
558
- {
559
- prof_profile_t* profile = prof_get_profile(self);
560
- return profile-&gt;running;
561
- }</pre>
562
- </div>
563
-
564
- </div>
565
-
566
-
567
-
568
-
569
- </div>
570
-
571
-
572
- <div id="method-i-start" class="method-detail ">
573
-
574
-
575
- <div class="method-heading">
576
- <span class="method-callseq">
577
- start &rarr; RubyProf
578
- </span>
579
-
580
- <span class="method-click-advice">click to toggle source</span>
581
-
582
- </div>
583
-
584
-
585
-
586
- <div class="method-description">
587
-
588
- <p>Starts recording profile data.</p>
589
-
590
-
591
-
592
-
593
- <div class="method-source-code" id="start-source">
594
- <pre>static VALUE
595
- prof_start(VALUE self)
596
- {
597
- char* trace_file_name;
598
-
599
- prof_profile_t* profile = prof_get_profile(self);
600
-
601
- if (profile-&gt;running == Qtrue)
602
- {
603
- rb_raise(rb_eRuntimeError, &quot;RubyProf.start was already called&quot;);
604
- }
605
-
606
- profile-&gt;running = Qtrue;
607
- profile-&gt;paused = Qfalse;
608
- profile-&gt;last_thread_data = NULL;
609
-
610
-
611
- /* open trace file if environment wants it */
612
- trace_file_name = getenv(&quot;RUBY_PROF_TRACE&quot;);
613
- if (trace_file_name != NULL)
614
- {
615
- if (strcmp(trace_file_name, &quot;stdout&quot;) == 0)
616
- {
617
- trace_file = stdout;
618
- }
619
- else if (strcmp(trace_file_name, &quot;stderr&quot;) == 0)
620
- {
621
- trace_file = stderr;
622
- }
623
- else
624
- {
625
- trace_file = fopen(trace_file_name, &quot;w&quot;);
626
- }
627
- }
628
-
629
- prof_install_hook(self);
630
- return self;
631
- }</pre>
632
- </div>
633
-
634
- </div>
635
-
636
-
637
-
638
-
639
- </div>
640
-
641
-
642
- <div id="method-i-stop" class="method-detail ">
643
-
644
-
645
- <div class="method-heading">
646
- <span class="method-callseq">
647
- stop &rarr; self
648
- </span>
649
-
650
- <span class="method-click-advice">click to toggle source</span>
651
-
652
- </div>
653
-
654
-
655
-
656
- <div class="method-description">
657
-
658
- <p>Stops collecting profile data.</p>
659
-
660
-
661
-
662
-
663
- <div class="method-source-code" id="stop-source">
664
- <pre>static VALUE
665
- prof_stop(VALUE self)
666
- {
667
- prof_profile_t* profile = prof_get_profile(self);
668
-
669
- if (profile-&gt;running == Qfalse)
670
- {
671
- rb_raise(rb_eRuntimeError, &quot;RubyProf.start was not yet called&quot;);
672
- }
673
-
674
- prof_remove_hook();
675
-
676
- /* close trace file if open */
677
- if (trace_file != NULL)
678
- {
679
- if (trace_file !=stderr &amp;&amp; trace_file != stdout)
680
- {
681
- #ifdef _MSC_VER
682
- _fcloseall();
683
- #else
684
- fclose(trace_file);
685
- #endif
686
- }
687
- trace_file = NULL;
688
- }
689
-
690
- prof_pop_threads(profile);
691
-
692
- /* Unset the last_thread_data (very important!)
693
- and the threads table */
694
- profile-&gt;running = profile-&gt;paused = Qfalse;
695
- profile-&gt;last_thread_data = NULL;
696
-
697
- /* Post process result */
698
- rb_funcall(self, rb_intern(&quot;post_process&quot;) , 0);
699
-
700
- return self;
701
- }</pre>
702
- </div>
703
-
704
- </div>
705
-
706
-
707
-
708
-
709
- </div>
710
-
711
-
712
- <div id="method-i-threads" class="method-detail ">
713
-
714
-
715
- <div class="method-heading">
716
- <span class="method-callseq">
717
- threads &rarr; Array of RubyProf::Thread
718
- </span>
719
-
720
- <span class="method-click-advice">click to toggle source</span>
721
-
722
- </div>
723
-
724
-
725
-
726
- <div class="method-description">
727
-
728
- <p>Returns an array of <a href="Thread.html">RubyProf::Thread</a> instances
729
- that were executed while the the program was being run.</p>
730
-
731
-
732
-
733
-
734
- <div class="method-source-code" id="threads-source">
735
- <pre>static VALUE
736
- prof_threads(VALUE self)
737
- {
738
- VALUE result = rb_ary_new();
739
- prof_profile_t* profile = prof_get_profile(self);
740
- st_foreach(profile-&gt;threads_tbl, collect_threads, result);
741
- return result;
742
- }</pre>
743
- </div>
744
-
745
- </div>
746
-
747
-
748
-
749
-
750
- </div>
751
-
752
-
753
- </section>
754
-
755
- </section>
756
- </main>
757
-
758
-
759
- <footer id="validator-badges" role="contentinfo">
760
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
761
- <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
762
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
763
- </footer>
764
-