ruby-prof 0.15.4 → 0.15.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +7 -1
- data/README.rdoc +1 -1
- data/bin/ruby-prof +16 -4
- data/doc/LICENSE.html +114 -0
- data/doc/README_rdoc.html +592 -0
- data/doc/Rack.html +95 -0
- data/doc/Rack/RubyProf.html +264 -0
- data/doc/RubyProf.html +962 -0
- data/doc/RubyProf/AbstractPrinter.html +546 -0
- data/doc/RubyProf/AggregateCallInfo.html +537 -0
- data/doc/RubyProf/CallInfo.html +468 -0
- data/doc/RubyProf/CallInfoPrinter.html +120 -0
- data/doc/RubyProf/CallInfoVisitor.html +200 -0
- data/doc/RubyProf/CallStackPrinter.html +1604 -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 +575 -0
- data/doc/RubyProf/GraphPrinter.html +139 -0
- data/doc/RubyProf/MethodInfo.html +685 -0
- data/doc/RubyProf/MultiPrinter.html +358 -0
- data/doc/RubyProf/Profile.html +764 -0
- data/doc/RubyProf/ProfileTask.html +490 -0
- data/doc/RubyProf/Thread.html +199 -0
- data/doc/created.rid +14 -14
- data/doc/examples/flat_txt.html +149 -0
- data/doc/examples/graph_html.html +850 -0
- data/doc/examples/graph_txt.html +274 -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 +618 -0
- data/doc/js/search_index.js.gz +0 -0
- data/doc/table_of_contents.html +859 -0
- data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +21 -14
- data/lib/ruby-prof/printers/graph_printer.rb +1 -0
- data/lib/ruby-prof/version.rb +1 -1
- data/test/measure_cpu_time_test.rb +1 -1
- metadata +54 -2
@@ -0,0 +1,257 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class RubyProf::DotPrinter - 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"><a href="AbstractPrinter.html">RubyProf::AbstractPrinter</a>
|
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 class="calls-super" ><a href="#method-c-new">::new</a>
|
74
|
+
|
75
|
+
<li ><a href="#method-i-print">#print</a>
|
76
|
+
|
77
|
+
</ul>
|
78
|
+
</div>
|
79
|
+
|
80
|
+
</div>
|
81
|
+
</nav>
|
82
|
+
|
83
|
+
<main role="main" aria-labelledby="class-RubyProf::DotPrinter">
|
84
|
+
<h1 id="class-RubyProf::DotPrinter" class="class">
|
85
|
+
class RubyProf::DotPrinter
|
86
|
+
</h1>
|
87
|
+
|
88
|
+
<section class="description">
|
89
|
+
|
90
|
+
<p>Generates a graphviz graph in dot format. To use the dot printer:</p>
|
91
|
+
|
92
|
+
<pre>result = RubyProf.profile do
|
93
|
+
[code to profile]
|
94
|
+
end
|
95
|
+
|
96
|
+
printer = RubyProf::DotPrinter.new(result)
|
97
|
+
printer.print(STDOUT)</pre>
|
98
|
+
|
99
|
+
<p>You can use either dot viewer such as GraphViz, or the dot command line
|
100
|
+
tool to reformat the output into a wide variety of outputs:</p>
|
101
|
+
|
102
|
+
<pre>dot -Tpng graph.dot > graph.png</pre>
|
103
|
+
|
104
|
+
</section>
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
<section class="constants-list">
|
116
|
+
<header>
|
117
|
+
<h3>Constants</h3>
|
118
|
+
</header>
|
119
|
+
<dl>
|
120
|
+
|
121
|
+
<dt id="CLASS_COLOR">CLASS_COLOR
|
122
|
+
|
123
|
+
<dd>
|
124
|
+
|
125
|
+
|
126
|
+
<dt id="EDGE_COLOR">EDGE_COLOR
|
127
|
+
|
128
|
+
<dd>
|
129
|
+
|
130
|
+
|
131
|
+
</dl>
|
132
|
+
</section>
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
139
|
+
<header>
|
140
|
+
<h3>Public Class Methods</h3>
|
141
|
+
</header>
|
142
|
+
|
143
|
+
|
144
|
+
<div id="method-c-new" class="method-detail ">
|
145
|
+
|
146
|
+
<div class="method-heading">
|
147
|
+
<span class="method-name">new</span><span
|
148
|
+
class="method-args">(result)</span>
|
149
|
+
|
150
|
+
<span class="method-click-advice">click to toggle source</span>
|
151
|
+
|
152
|
+
</div>
|
153
|
+
|
154
|
+
|
155
|
+
<div class="method-description">
|
156
|
+
|
157
|
+
<p>Creates the <a href="DotPrinter.html">DotPrinter</a> using a
|
158
|
+
RubyProf::Result.</p>
|
159
|
+
|
160
|
+
|
161
|
+
<div class="method-calls-super">
|
162
|
+
Calls superclass method
|
163
|
+
<a href="AbstractPrinter.html#method-c-new">RubyProf::AbstractPrinter.new</a>
|
164
|
+
</div>
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
<div class="method-source-code" id="new-source">
|
169
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/dot_printer.rb, line 25</span>
|
170
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">result</span>)
|
171
|
+
<span class="ruby-keyword">super</span>(<span class="ruby-identifier">result</span>)
|
172
|
+
<span class="ruby-ivar">@seen_methods</span> = <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>
|
173
|
+
<span class="ruby-keyword">end</span></pre>
|
174
|
+
</div>
|
175
|
+
|
176
|
+
</div>
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
</div>
|
182
|
+
|
183
|
+
|
184
|
+
</section>
|
185
|
+
|
186
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
187
|
+
<header>
|
188
|
+
<h3>Public Instance Methods</h3>
|
189
|
+
</header>
|
190
|
+
|
191
|
+
|
192
|
+
<div id="method-i-print" class="method-detail ">
|
193
|
+
|
194
|
+
<div class="method-heading">
|
195
|
+
<span class="method-name">print</span><span
|
196
|
+
class="method-args">(output = STDOUT, options = {})</span>
|
197
|
+
|
198
|
+
<span class="method-click-advice">click to toggle source</span>
|
199
|
+
|
200
|
+
</div>
|
201
|
+
|
202
|
+
|
203
|
+
<div class="method-description">
|
204
|
+
|
205
|
+
<p>Print a graph report to the provided output.</p>
|
206
|
+
|
207
|
+
<p>output - Any IO object, including STDOUT or a file. The default value is
|
208
|
+
STDOUT.</p>
|
209
|
+
|
210
|
+
<p>options - Hash of print options. See <a
|
211
|
+
href="AbstractPrinter.html#method-i-setup_options">setup_options</a> for
|
212
|
+
more information.</p>
|
213
|
+
|
214
|
+
<p>When profiling results that cover a large number of method calls it helps
|
215
|
+
to use the :min_percent option, for example:</p>
|
216
|
+
|
217
|
+
<pre class="ruby"><span class="ruby-constant">DotPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>).<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, :<span class="ruby-identifier">min_percent=</span><span class="ruby-operator">></span><span class="ruby-value">5</span>)
|
218
|
+
</pre>
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
<div class="method-source-code" id="print-source">
|
224
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/dot_printer.rb, line 43</span>
|
225
|
+
<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> = {})
|
226
|
+
<span class="ruby-ivar">@output</span> = <span class="ruby-identifier">output</span>
|
227
|
+
<span class="ruby-identifier">setup_options</span>(<span class="ruby-identifier">options</span>)
|
228
|
+
|
229
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">'digraph "Profile" {'</span>
|
230
|
+
<span class="ruby-comment">#puts "label=\"#{mode_name} >=#{min_percent}%\\nTotal: #{total_time}\";"</span>
|
231
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">"labelloc=t;"</span>
|
232
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">"labeljust=l;"</span>
|
233
|
+
<span class="ruby-identifier">print_threads</span>
|
234
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-string">'}'</span>
|
235
|
+
<span class="ruby-keyword">end</span></pre>
|
236
|
+
</div>
|
237
|
+
|
238
|
+
</div>
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
</div>
|
244
|
+
|
245
|
+
|
246
|
+
</section>
|
247
|
+
|
248
|
+
</section>
|
249
|
+
</main>
|
250
|
+
|
251
|
+
|
252
|
+
<footer id="validator-badges" role="contentinfo">
|
253
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
254
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
255
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
256
|
+
</footer>
|
257
|
+
|
@@ -0,0 +1,163 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class RubyProf::FlatPrinter - 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"><a href="AbstractPrinter.html">RubyProf::AbstractPrinter</a>
|
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-i-sort_method">#sort_method</a>
|
74
|
+
|
75
|
+
</ul>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
</div>
|
79
|
+
</nav>
|
80
|
+
|
81
|
+
<main role="main" aria-labelledby="class-RubyProf::FlatPrinter">
|
82
|
+
<h1 id="class-RubyProf::FlatPrinter" class="class">
|
83
|
+
class RubyProf::FlatPrinter
|
84
|
+
</h1>
|
85
|
+
|
86
|
+
<section class="description">
|
87
|
+
|
88
|
+
<p>Generates <a href="../files/examples/flat_txt.html">flat</a> profile
|
89
|
+
reports as text. To use the flat printer:</p>
|
90
|
+
|
91
|
+
<pre>result = RubyProf.profile do
|
92
|
+
[code to profile]
|
93
|
+
end
|
94
|
+
|
95
|
+
printer = RubyProf::FlatPrinter.new(result)
|
96
|
+
printer.print(STDOUT, {})</pre>
|
97
|
+
|
98
|
+
</section>
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
114
|
+
<header>
|
115
|
+
<h3>Public Instance Methods</h3>
|
116
|
+
</header>
|
117
|
+
|
118
|
+
|
119
|
+
<div id="method-i-sort_method" class="method-detail ">
|
120
|
+
|
121
|
+
<div class="method-heading">
|
122
|
+
<span class="method-name">sort_method</span><span
|
123
|
+
class="method-args">()</span>
|
124
|
+
|
125
|
+
<span class="method-click-advice">click to toggle source</span>
|
126
|
+
|
127
|
+
</div>
|
128
|
+
|
129
|
+
|
130
|
+
<div class="method-description">
|
131
|
+
|
132
|
+
<p>Override for this printer to sort by self time by default</p>
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<div class="method-source-code" id="sort_method-source">
|
138
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/flat_printer.rb, line 15</span>
|
139
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">sort_method</span>
|
140
|
+
<span class="ruby-ivar">@options</span>[<span class="ruby-value">:sort_method</span>] <span class="ruby-operator">||</span> <span class="ruby-value">:self_time</span>
|
141
|
+
<span class="ruby-keyword">end</span></pre>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
</div>
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
</div>
|
150
|
+
|
151
|
+
|
152
|
+
</section>
|
153
|
+
|
154
|
+
</section>
|
155
|
+
</main>
|
156
|
+
|
157
|
+
|
158
|
+
<footer id="validator-badges" role="contentinfo">
|
159
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
160
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
161
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
162
|
+
</footer>
|
163
|
+
|
@@ -0,0 +1,208 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class RubyProf::FlatPrinterWithLineNumbers - 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"><a href="FlatPrinter.html">RubyProf::FlatPrinter</a>
|
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-i-print_methods">#print_methods</a>
|
74
|
+
|
75
|
+
</ul>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
</div>
|
79
|
+
</nav>
|
80
|
+
|
81
|
+
<main role="main" aria-labelledby="class-RubyProf::FlatPrinterWithLineNumbers">
|
82
|
+
<h1 id="class-RubyProf::FlatPrinterWithLineNumbers" class="class">
|
83
|
+
class RubyProf::FlatPrinterWithLineNumbers
|
84
|
+
</h1>
|
85
|
+
|
86
|
+
<section class="description">
|
87
|
+
|
88
|
+
<p>Generates <a href="../files/examples/flat_txt.html">flat</a> profile
|
89
|
+
reports as text. To use the flat printer with line numbers:</p>
|
90
|
+
|
91
|
+
<pre>result = RubyProf.profile do
|
92
|
+
[code to profile]
|
93
|
+
end
|
94
|
+
|
95
|
+
printer = RubyProf::FlatPrinterWithLineNumbers.new(result)
|
96
|
+
printer.print(STDOUT, {})</pre>
|
97
|
+
|
98
|
+
</section>
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
114
|
+
<header>
|
115
|
+
<h3>Public Instance Methods</h3>
|
116
|
+
</header>
|
117
|
+
|
118
|
+
|
119
|
+
<div id="method-i-print_methods" class="method-detail ">
|
120
|
+
|
121
|
+
<div class="method-heading">
|
122
|
+
<span class="method-name">print_methods</span><span
|
123
|
+
class="method-args">(thread)</span>
|
124
|
+
|
125
|
+
<span class="method-click-advice">click to toggle source</span>
|
126
|
+
|
127
|
+
</div>
|
128
|
+
|
129
|
+
|
130
|
+
<div class="method-description">
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<div class="method-source-code" id="print_methods-source">
|
138
|
+
<pre><span class="ruby-comment"># File lib/ruby-prof/printers/flat_printer_with_line_numbers.rb, line 14</span>
|
139
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">print_methods</span>(<span class="ruby-identifier">thread</span>)
|
140
|
+
<span class="ruby-identifier">total_time</span> = <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">total_time</span>
|
141
|
+
|
142
|
+
<span class="ruby-identifier">methods</span> = <span class="ruby-identifier">thread</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">sort_by</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">sort_method</span>).<span class="ruby-identifier">reverse</span>
|
143
|
+
<span class="ruby-identifier">sum</span> = <span class="ruby-value">0</span>
|
144
|
+
<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span>
|
145
|
+
<span class="ruby-identifier">self_percent</span> = (<span class="ruby-identifier">method</span>.<span class="ruby-identifier">self_time</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">total_time</span>) <span class="ruby-operator">*</span> <span class="ruby-value">100</span>
|
146
|
+
<span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">self_percent</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">min_percent</span>
|
147
|
+
|
148
|
+
<span class="ruby-identifier">sum</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">self_time</span>
|
149
|
+
<span class="ruby-comment">#self_time_called = method.called > 0 ? method.self_time/method.called : 0</span>
|
150
|
+
<span class="ruby-comment">#total_time_called = method.called > 0? method.total_time/method.called : 0</span>
|
151
|
+
|
152
|
+
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"%6.2f %9.3f %9.3f %9.3f %9.3f %8d %s%s"</span> <span class="ruby-operator">%</span> [
|
153
|
+
<span class="ruby-identifier">method</span>.<span class="ruby-identifier">self_time</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">total_time</span> <span class="ruby-operator">*</span> <span class="ruby-value">100</span>, <span class="ruby-comment"># %self</span>
|
154
|
+
<span class="ruby-identifier">method</span>.<span class="ruby-identifier">total_time</span>, <span class="ruby-comment"># total</span>
|
155
|
+
<span class="ruby-identifier">method</span>.<span class="ruby-identifier">self_time</span>, <span class="ruby-comment"># self</span>
|
156
|
+
<span class="ruby-identifier">method</span>.<span class="ruby-identifier">wait_time</span>, <span class="ruby-comment"># wait</span>
|
157
|
+
<span class="ruby-identifier">method</span>.<span class="ruby-identifier">children_time</span>, <span class="ruby-comment"># children</span>
|
158
|
+
<span class="ruby-identifier">method</span>.<span class="ruby-identifier">called</span>, <span class="ruby-comment"># calls</span>
|
159
|
+
<span class="ruby-identifier">method</span>.<span class="ruby-identifier">recursive?</span> <span class="ruby-operator">?</span> <span class="ruby-string">"*"</span> <span class="ruby-operator">:</span> <span class="ruby-string">" "</span>, <span class="ruby-comment"># cycle</span>
|
160
|
+
<span class="ruby-identifier">method_name</span>(<span class="ruby-identifier">method</span>) <span class="ruby-comment"># name</span>
|
161
|
+
]
|
162
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">source_file</span> <span class="ruby-operator">==</span> <span class="ruby-string">'ruby_runtime'</span>
|
163
|
+
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"\n"</span>
|
164
|
+
<span class="ruby-keyword">else</span>
|
165
|
+
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"\n defined at:\n"</span>
|
166
|
+
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-string">" %s:%s\n"</span> <span class="ruby-operator">%</span> [<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>), <span class="ruby-identifier">method</span>.<span class="ruby-identifier">line</span>]
|
167
|
+
<span class="ruby-keyword">end</span>
|
168
|
+
|
169
|
+
<span class="ruby-identifier">callers</span> = []
|
170
|
+
<span class="ruby-identifier">method</span>.<span class="ruby-identifier">call_infos</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ci</span><span class="ruby-operator">|</span>
|
171
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">ci</span>.<span class="ruby-identifier">parent</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">ci</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">target</span>.<span class="ruby-identifier">source_file</span> <span class="ruby-operator">!=</span> <span class="ruby-string">'ruby_runtime'</span>
|
172
|
+
<span class="ruby-identifier">callers</span> <span class="ruby-operator"><<</span> [<span class="ruby-identifier">method_name</span>(<span class="ruby-identifier">ci</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">target</span>), <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">ci</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">target</span>.<span class="ruby-identifier">source_file</span>), <span class="ruby-identifier">ci</span>.<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">target</span>.<span class="ruby-identifier">line</span>]
|
173
|
+
<span class="ruby-keyword">end</span>
|
174
|
+
<span class="ruby-keyword">end</span>
|
175
|
+
<span class="ruby-comment"># make sure callers are unique</span>
|
176
|
+
<span class="ruby-identifier">callers</span>.<span class="ruby-identifier">uniq!</span>
|
177
|
+
|
178
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">callers</span>.<span class="ruby-identifier">empty?</span>
|
179
|
+
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-string">" called from:\n"</span>
|
180
|
+
<span class="ruby-identifier">callers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span>
|
181
|
+
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-string">" %s (%s:%s)\n"</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">args</span>
|
182
|
+
<span class="ruby-keyword">end</span>
|
183
|
+
<span class="ruby-keyword">end</span>
|
184
|
+
<span class="ruby-ivar">@output</span> <span class="ruby-operator"><<</span> <span class="ruby-string">"\n"</span>
|
185
|
+
<span class="ruby-keyword">end</span>
|
186
|
+
<span class="ruby-keyword">end</span></pre>
|
187
|
+
</div>
|
188
|
+
|
189
|
+
</div>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
</div>
|
195
|
+
|
196
|
+
|
197
|
+
</section>
|
198
|
+
|
199
|
+
</section>
|
200
|
+
</main>
|
201
|
+
|
202
|
+
|
203
|
+
<footer id="validator-badges" role="contentinfo">
|
204
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
205
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
206
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
207
|
+
</footer>
|
208
|
+
|