ruby-prof 0.15.2 → 0.15.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/doc/LICENSE.html +11 -14
- data/doc/README_rdoc.html +106 -109
- data/doc/Rack.html +6 -9
- data/doc/Rack/RubyProf.html +12 -15
- data/doc/RubyProf.html +11 -13
- data/doc/RubyProf/AbstractPrinter.html +7 -10
- data/doc/RubyProf/AggregateCallInfo.html +6 -9
- data/doc/RubyProf/CallInfo.html +8 -11
- data/doc/RubyProf/CallInfoPrinter.html +7 -10
- data/doc/RubyProf/CallInfoVisitor.html +6 -9
- data/doc/RubyProf/CallStackPrinter.html +48 -51
- data/doc/RubyProf/CallTreePrinter.html +14 -17
- data/doc/RubyProf/Cmd.html +44 -47
- data/doc/RubyProf/DotPrinter.html +8 -11
- data/doc/RubyProf/FlatPrinter.html +6 -9
- data/doc/RubyProf/FlatPrinterWithLineNumbers.html +9 -12
- data/doc/RubyProf/GraphHtmlPrinter.html +14 -18
- data/doc/RubyProf/GraphPrinter.html +6 -9
- data/doc/RubyProf/MethodInfo.html +8 -11
- data/doc/RubyProf/MultiPrinter.html +6 -9
- data/doc/RubyProf/Profile.html +7 -10
- data/doc/RubyProf/ProfileTask.html +18 -20
- data/doc/RubyProf/Thread.html +6 -9
- data/doc/created.rid +4 -4
- data/doc/{fonts.css → css/fonts.css} +0 -0
- data/doc/{rdoc.css → css/rdoc.css} +11 -1
- data/doc/examples/flat_txt.html +8 -11
- data/doc/examples/graph_html.html +8 -10
- data/doc/examples/graph_txt.html +13 -16
- data/doc/index.html +108 -109
- data/doc/js/darkfish.js +32 -11
- data/doc/js/jquery.js +4 -18
- 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 +9 -9
- data/ext/ruby_prof/ruby_prof.c +2 -2
- data/lib/ruby-prof/version.rb +1 -1
- data/ruby-prof.gemspec +1 -1
- data/test/aggregate_test.rb +1 -1
- data/test/basic_test.rb +5 -5
- data/test/block_test.rb +74 -0
- data/test/call_info_test.rb +1 -1
- data/test/call_info_visitor_test.rb +1 -1
- data/test/duplicate_names_test.rb +1 -1
- data/test/dynamic_method_test.rb +37 -56
- data/test/enumerable_test.rb +7 -2
- data/test/exceptions_test.rb +2 -2
- data/test/exclude_threads_test.rb +1 -1
- data/test/fiber_test.rb +1 -1
- data/test/line_number_test.rb +1 -1
- data/test/measure_allocations_test.rb +1 -1
- data/test/measure_cpu_time_test.rb +1 -1
- data/test/measure_gc_runs_test.rb +1 -1
- data/test/measure_gc_time_test.rb +1 -1
- data/test/measure_memory_test.rb +2 -2
- data/test/measure_process_time_test.rb +1 -1
- data/test/measure_wall_time_test.rb +2 -2
- data/test/method_elimination_test.rb +1 -1
- data/test/module_test.rb +1 -1
- data/test/multi_printer_test.rb +1 -1
- data/test/pause_resume_test.rb +1 -1
- data/test/printers_test.rb +5 -5
- data/test/rack_test.rb +2 -2
- data/test/recursive_test.rb +1 -1
- data/test/singleton_test.rb +1 -1
- data/test/stack_printer_test.rb +1 -1
- data/test/stack_test.rb +1 -1
- data/test/start_stop_test.rb +4 -4
- data/test/test_helper.rb +8 -1
- data/test/thread_test.rb +1 -1
- data/test/unique_call_path_test.rb +2 -2
- data/test/yarv_test.rb +1 -1
- metadata +64 -71
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1200061e7b192038f2d85ae302c2b4f4243d9880
|
4
|
+
data.tar.gz: 5a82e1b0fd2a6ff260afd1adbd8218bb11458db3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce8f0674d1f6736b0383e5e9bececf0f8cc5a3898d6a3288a4fd62501032116720ff7869d073ea75a92524a3a6ffa43c8a68f23dae0a2cd9f123fd9aebdbcf91
|
7
|
+
data.tar.gz: b2ad4dfd01e84d3283f1391fa329a9b89c2d776569d06229ed336b16bea3faaf6bf9c55c3610c9977c2af7e76a6d010380208e9c50407f224861b4125782e6c3
|
data/doc/LICENSE.html
CHANGED
@@ -6,20 +6,17 @@
|
|
6
6
|
|
7
7
|
<title>LICENSE - ruby-prof</title>
|
8
8
|
|
9
|
-
<link href="./fonts.css" rel="stylesheet">
|
10
|
-
<link href="./rdoc.css" rel="stylesheet">
|
11
|
-
|
12
9
|
<script type="text/javascript">
|
13
10
|
var rdoc_rel_prefix = "./";
|
14
11
|
</script>
|
15
12
|
|
16
13
|
<script src="./js/jquery.js"></script>
|
17
|
-
<script src="./js/navigation.js"></script>
|
18
|
-
<script src="./js/search_index.js"></script>
|
19
|
-
<script src="./js/search.js"></script>
|
20
|
-
<script src="./js/searcher.js"></script>
|
21
14
|
<script src="./js/darkfish.js"></script>
|
22
15
|
|
16
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
17
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
18
|
+
|
19
|
+
|
23
20
|
|
24
21
|
<body id="top" role="document" class="file">
|
25
22
|
<nav role="navigation">
|
@@ -94,11 +91,11 @@ this list of conditions and the following disclaimer in the documentation
|
|
94
91
|
and/or other materials provided with the distribution.</p>
|
95
92
|
</li></ol>
|
96
93
|
|
97
|
-
<p>THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS “AS IS
|
98
|
-
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
99
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
100
|
-
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
101
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
94
|
+
<p>THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS “AS IS''
|
95
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
96
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
97
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
98
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
102
99
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
103
100
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
104
101
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
@@ -111,7 +108,7 @@ DAMAGE.</p>
|
|
111
108
|
|
112
109
|
<footer id="validator-badges" role="contentinfo">
|
113
110
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
114
|
-
<p>Generated by <a href="http://
|
115
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-
|
111
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
112
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
116
113
|
</footer>
|
117
114
|
|
data/doc/README_rdoc.html
CHANGED
@@ -6,20 +6,17 @@
|
|
6
6
|
|
7
7
|
<title>README - ruby-prof</title>
|
8
8
|
|
9
|
-
<link href="./fonts.css" rel="stylesheet">
|
10
|
-
<link href="./rdoc.css" rel="stylesheet">
|
11
|
-
|
12
9
|
<script type="text/javascript">
|
13
10
|
var rdoc_rel_prefix = "./";
|
14
11
|
</script>
|
15
12
|
|
16
13
|
<script src="./js/jquery.js"></script>
|
17
|
-
<script src="./js/navigation.js"></script>
|
18
|
-
<script src="./js/search_index.js"></script>
|
19
|
-
<script src="./js/search.js"></script>
|
20
|
-
<script src="./js/searcher.js"></script>
|
21
14
|
<script src="./js/darkfish.js"></script>
|
22
15
|
|
16
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
17
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
18
|
+
|
19
|
+
|
23
20
|
|
24
21
|
<body id="top" role="document" class="file">
|
25
22
|
<nav role="navigation">
|
@@ -103,13 +100,13 @@
|
|
103
100
|
|
104
101
|
<main role="main" aria-label="Page README.rdoc">
|
105
102
|
|
106
|
-
<h1 id="label-ruby-prof">ruby-prof<span><a href="#label-ruby-prof">¶</a> <a href="#
|
103
|
+
<h1 id="label-ruby-prof">ruby-prof<span><a href="#label-ruby-prof">¶</a> <a href="#top">↑</a></span></h1>
|
107
104
|
|
108
105
|
<p><a href="https://travis-ci.org/ruby-prof/ruby-prof"><img
|
109
106
|
src="https://travis-ci.org/ruby-prof/ruby-prof.png?branch=master"
|
110
107
|
alt="Build Status" /></a></p>
|
111
108
|
|
112
|
-
<h2 id="label-Overview">Overview<span><a href="#label-Overview">¶</a> <a href="#
|
109
|
+
<h2 id="label-Overview">Overview<span><a href="#label-Overview">¶</a> <a href="#top">↑</a></span></h2>
|
113
110
|
|
114
111
|
<p>ruby-prof is a fast code profiler for Ruby. Its features include:</p>
|
115
112
|
<ul><li>
|
@@ -137,119 +134,117 @@ href="README_rdoc.html">README</a>.</p>
|
|
137
134
|
<p>Threads - supports profiling multiple threads simultaneously</p>
|
138
135
|
</li></ul>
|
139
136
|
|
140
|
-
<h2 id="label-Requirements">Requirements<span><a href="#label-Requirements">¶</a> <a href="#
|
137
|
+
<h2 id="label-Requirements">Requirements<span><a href="#label-Requirements">¶</a> <a href="#top">↑</a></span></h2>
|
141
138
|
|
142
139
|
<p>ruby-prof requires Ruby 1.9.3 or higher.</p>
|
143
140
|
|
144
|
-
<p>If you are running Linux or Unix you
|
145
|
-
can be compiled when it is installed.</p>
|
141
|
+
<p>If you are running Linux or Unix you'll need a C compiler so the
|
142
|
+
extension can be compiled when it is installed.</p>
|
146
143
|
|
147
144
|
<p>If you are running Windows, then you may need to install the Windows
|
148
145
|
specific RubyGem which includes an already built extension (see Install
|
149
146
|
section).</p>
|
150
147
|
|
151
|
-
<h2 id="label-Install">Install<span><a href="#label-Install">¶</a> <a href="#
|
148
|
+
<h2 id="label-Install">Install<span><a href="#label-Install">¶</a> <a href="#top">↑</a></span></h2>
|
152
149
|
|
153
150
|
<p>The easiest way to install ruby-prof is by using Ruby Gems. To install:</p>
|
154
151
|
|
155
|
-
<pre>gem install ruby-prof</
|
152
|
+
<pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-identifier">install</span> <span class="ruby-identifier">ruby</span><span class="ruby-operator">-</span><span class="ruby-identifier">prof</span>
|
153
|
+
</pre>
|
156
154
|
|
157
|
-
<p>If you
|
158
|
-
compile.</p>
|
155
|
+
<p>If you're on windows then please install the devkit first so that it
|
156
|
+
can compile.</p>
|
159
157
|
|
160
|
-
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#
|
158
|
+
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#top">↑</a></span></h2>
|
161
159
|
|
162
160
|
<p>There are two ways of running ruby-prof, via the command line or via its
|
163
161
|
API.</p>
|
164
162
|
|
165
|
-
<h3 id="label-ruby-prof+executable">ruby-prof executable<span><a href="#label-ruby-prof+executable">¶</a> <a href="#
|
163
|
+
<h3 id="label-ruby-prof+executable">ruby-prof executable<span><a href="#label-ruby-prof+executable">¶</a> <a href="#top">↑</a></span></h3>
|
166
164
|
|
167
165
|
<p>The first is to use ruby-prof to run the Ruby program you want to profile.
|
168
166
|
For more information refer to the documentation of the ruby-prof command.</p>
|
169
167
|
|
170
|
-
<h3 id="label-ruby-prof+API">ruby-prof API<span><a href="#label-ruby-prof+API">¶</a> <a href="#
|
168
|
+
<h3 id="label-ruby-prof+API">ruby-prof API<span><a href="#label-ruby-prof+API">¶</a> <a href="#top">↑</a></span></h3>
|
171
169
|
|
172
170
|
<p>The second way is to use the ruby-prof API to profile particular segments
|
173
171
|
of code.</p>
|
174
172
|
|
175
|
-
<pre
|
173
|
+
<pre>require 'ruby-prof'
|
176
174
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
[
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
</pre>
|
175
|
+
# Profile the code
|
176
|
+
RubyProf.start
|
177
|
+
...
|
178
|
+
[code to profile]
|
179
|
+
...
|
180
|
+
result = RubyProf.stop
|
181
|
+
|
182
|
+
# Print a flat profile to text
|
183
|
+
printer = RubyProf::FlatPrinter.new(result)
|
184
|
+
printer.print(STDOUT)</pre>
|
188
185
|
|
189
186
|
<p>Alternatively, you can use a block to tell ruby-prof what to profile:</p>
|
190
187
|
|
191
|
-
<pre
|
188
|
+
<pre>require 'ruby-prof'
|
192
189
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
[
|
197
|
-
|
198
|
-
|
190
|
+
# Profile the code
|
191
|
+
result = RubyProf.profile do
|
192
|
+
...
|
193
|
+
[code to profile]
|
194
|
+
...
|
195
|
+
end
|
199
196
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
</pre>
|
197
|
+
# Print a graph profile to text
|
198
|
+
printer = RubyProf::GraphPrinter.new(result)
|
199
|
+
printer.print(STDOUT, {})</pre>
|
204
200
|
|
205
201
|
<p>ruby-prof also supports pausing and resuming profiling runs.</p>
|
206
202
|
|
207
|
-
<pre
|
203
|
+
<pre>require 'ruby-prof'
|
208
204
|
|
209
|
-
|
210
|
-
|
211
|
-
[
|
212
|
-
|
213
|
-
[
|
214
|
-
|
215
|
-
[
|
216
|
-
|
217
|
-
</pre>
|
205
|
+
# Profile the code
|
206
|
+
RubyProf.start
|
207
|
+
[code to profile]
|
208
|
+
RubyProf.pause
|
209
|
+
[other code]
|
210
|
+
RubyProf.resume
|
211
|
+
[code to profile]
|
212
|
+
result = RubyProf.stop</pre>
|
218
213
|
|
219
214
|
<p>Note that resume will automatically call start if a profiling run has not
|
220
215
|
yet started. In addition, resume can also take a block:</p>
|
221
216
|
|
222
|
-
<pre
|
217
|
+
<pre>require 'ruby-prof'
|
223
218
|
|
224
|
-
|
225
|
-
|
226
|
-
[
|
227
|
-
|
219
|
+
# Profile the code
|
220
|
+
RubyProf.resume do
|
221
|
+
[code to profile]
|
222
|
+
end
|
228
223
|
|
229
|
-
|
230
|
-
</pre>
|
224
|
+
data = RubyProf.stop</pre>
|
231
225
|
|
232
226
|
<p>With this usage, resume will automatically call pause at the end of the
|
233
227
|
block.</p>
|
234
228
|
|
235
|
-
<h2 id="label-Method+and+Thread+Elimination">Method and Thread Elimination<span><a href="#label-Method+and+Thread+Elimination">¶</a> <a href="#
|
229
|
+
<h2 id="label-Method+and+Thread+Elimination">Method and Thread Elimination<span><a href="#label-Method+and+Thread+Elimination">¶</a> <a href="#top">↑</a></span></h2>
|
236
230
|
|
237
231
|
<p>ruby-prof supports eliminating specific methods and threads from profiling
|
238
232
|
results. This is useful for reducing connectivity in the call graph, making
|
239
233
|
it easier to identify the source of performance problems when using a graph
|
240
234
|
printer.</p>
|
241
235
|
|
242
|
-
<p>For example, consider Integer#times: it
|
243
|
-
much time is spent in the method itself. We
|
244
|
-
much the passed in block contributes to the time spent in the method
|
245
|
-
contains the Integer#times call.</p>
|
236
|
+
<p>For example, consider Integer#times: it's hardly ever useful to know
|
237
|
+
how much time is spent in the method itself. We're much more interested
|
238
|
+
in how much the passed in block contributes to the time spent in the method
|
239
|
+
which contains the Integer#times call.</p>
|
246
240
|
|
247
241
|
<p>Methods are eliminated from the collected data by calling
|
248
242
|
`eliminate_methods!` on the profiling result, before submitting it to a
|
249
243
|
printer.</p>
|
250
244
|
|
251
|
-
<pre>result = RubyProf
|
252
|
-
result
|
245
|
+
<pre class="ruby"><span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
|
246
|
+
<span class="ruby-identifier">result</span>.<span class="ruby-identifier">eliminate_methods!</span>([<span class="ruby-node">/Integer#times/</span>])
|
247
|
+
</pre>
|
253
248
|
|
254
249
|
<p>The argument given to `eliminate_methods!` is either an array of regular
|
255
250
|
expressions, or the name of a file containing a list of regular expressions
|
@@ -261,17 +256,19 @@ those methods had been inlined at their call sites.</p>
|
|
261
256
|
<p>In a similar manner, threads can be excluded so they are not profiled at
|
262
257
|
all. To do this, pass an array of threads to exclude to ruby-prof:</p>
|
263
258
|
|
264
|
-
<pre>RubyProf
|
265
|
-
RubyProf
|
259
|
+
<pre class="ruby"><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-identifier">exclude_threads</span> = [ <span class="ruby-identifier">thread2</span> ]
|
260
|
+
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
|
261
|
+
</pre>
|
266
262
|
|
267
263
|
<p>Note that the excluded threads must be specified <strong>before</strong>
|
268
264
|
profiling.</p>
|
269
265
|
|
270
|
-
<h2 id="label-Benchmarking+full+load+time+including+rubygems+startup+cost">Benchmarking full load time including rubygems startup cost<span><a href="#label-Benchmarking+full+load+time+including+rubygems+startup+cost">¶</a> <a href="#
|
266
|
+
<h2 id="label-Benchmarking+full+load+time+including+rubygems+startup+cost">Benchmarking full load time including rubygems startup cost<span><a href="#label-Benchmarking+full+load+time+including+rubygems+startup+cost">¶</a> <a href="#top">↑</a></span></h2>
|
271
267
|
|
272
|
-
<p>If you want to get a more accurate measurement of what takes all of a
|
273
|
-
bin/xxx command to load, you may want to also measure
|
274
|
-
penalty. You can do this by calling into
|
268
|
+
<p>If you want to get a more accurate measurement of what takes all of a
|
269
|
+
gem's bin/xxx command to load, you may want to also measure
|
270
|
+
rubygems' startup penalty. You can do this by calling into
|
271
|
+
bin/ruby-prof directly, ex:</p>
|
275
272
|
|
276
273
|
<p>$ gem which ruby-prof</p>
|
277
274
|
|
@@ -287,10 +284,10 @@ g:192binsome_installed_gem_command</p>
|
|
287
284
|
<p>$ ruby g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/bin/ruby-prof
|
288
285
|
./some_file_that_does_a_require_rubygems_at_the_beginning.rb</p>
|
289
286
|
|
290
|
-
<h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">¶</a> <a href="#
|
287
|
+
<h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">¶</a> <a href="#top">↑</a></span></h2>
|
291
288
|
|
292
289
|
<p>To profile a Rails application it is vital to run it using production like
|
293
|
-
settings (cache classes, cache view lookups, etc.). Otherwise, Rail
|
290
|
+
settings (cache classes, cache view lookups, etc.). Otherwise, Rail's
|
294
291
|
dependency loading code will overwhelm any time spent in the application
|
295
292
|
itself (our tests show that Rails dependency loading causes a roughly 6x
|
296
293
|
slowdown). The best way to do this is create a new Rails environment,
|
@@ -305,15 +302,16 @@ likely turn off caching.</p>
|
|
305
302
|
</li><li>
|
306
303
|
<p>Add the ruby-prof to your gemfile:</p>
|
307
304
|
|
308
|
-
<pre>group
|
309
|
-
gem
|
310
|
-
end</
|
305
|
+
<pre class="ruby"><span class="ruby-identifier">group</span> :<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
|
306
|
+
<span class="ruby-identifier">gem</span> <span class="ruby-string">'ruby-prof'</span>
|
307
|
+
<span class="ruby-keyword">end</span>
|
308
|
+
</pre>
|
311
309
|
</li><li>
|
312
310
|
<p>Add the ruby prof rack adapter to your middleware stack. One way to do
|
313
311
|
this is by adding the following code to config.ru:</p>
|
314
312
|
|
315
313
|
<pre class="ruby"><span class="ruby-keyword">if</span> <span class="ruby-constant">Rails</span>.<span class="ruby-identifier">env</span>.<span class="ruby-identifier">profile?</span>
|
316
|
-
<span class="ruby-identifier">use</span> <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span>, :<span class="ruby-identifier">path</span> =<span class="ruby-operator">></span> <span class="ruby-string"
|
314
|
+
<span class="ruby-identifier">use</span> <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span>, :<span class="ruby-identifier">path</span> =<span class="ruby-operator">></span> <span class="ruby-string">'/temp/profile'</span>
|
317
315
|
<span class="ruby-keyword">end</span>
|
318
316
|
</pre>
|
319
317
|
|
@@ -325,7 +323,7 @@ be generated for each request. Note that each request will overwrite the
|
|
325
323
|
profiling reports created by the previous request!</p>
|
326
324
|
</li></ol>
|
327
325
|
|
328
|
-
<h2 id="label-Reports">Reports<span><a href="#label-Reports">¶</a> <a href="#
|
326
|
+
<h2 id="label-Reports">Reports<span><a href="#label-Reports">¶</a> <a href="#top">↑</a></span></h2>
|
329
327
|
|
330
328
|
<p>ruby-prof can generate a number of different reports:</p>
|
331
329
|
<ul><li>
|
@@ -375,13 +373,13 @@ href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/call_stack.html
|
|
375
373
|
<p>Another good example: [<a
|
376
374
|
href="http://twitpic.com/28z94a">twitpic.com/28z94a</a>]</p>
|
377
375
|
|
378
|
-
<p>Finally, there
|
376
|
+
<p>Finally, there's a so called MultiPrinter which can generate several
|
379
377
|
reports in one profiling run. See <a
|
380
378
|
href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/multi.stack.html">examples/multi.stack.html</a>.</p>
|
381
379
|
|
382
380
|
<p>There is also a graphviz .dot visualiser.</p>
|
383
381
|
|
384
|
-
<h2 id="label-Printers">Printers<span><a href="#label-Printers">¶</a> <a href="#
|
382
|
+
<h2 id="label-Printers">Printers<span><a href="#label-Printers">¶</a> <a href="#top">↑</a></span></h2>
|
385
383
|
|
386
384
|
<p>Reports are created by printers. Supported printers include:</p>
|
387
385
|
<ul><li>
|
@@ -399,7 +397,7 @@ call graph report in text format</p>
|
|
399
397
|
Creates a call graph report in HTML (separate files per thread)</p>
|
400
398
|
</li><li>
|
401
399
|
<p><a href="RubyProf/DotPrinter.html">RubyProf::DotPrinter</a> - Creates a
|
402
|
-
call graph report in GraphViz
|
400
|
+
call graph report in GraphViz's DOT format which can be converted to an
|
403
401
|
image</p>
|
404
402
|
</li><li>
|
405
403
|
<p><a href="RubyProf/CallTreePrinter.html">RubyProf::CallTreePrinter</a> -
|
@@ -416,11 +414,10 @@ other printers to create several reports in one profiling run</p>
|
|
416
414
|
|
417
415
|
<p>To use a printer:</p>
|
418
416
|
|
419
|
-
<pre
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
</pre>
|
417
|
+
<pre>...
|
418
|
+
result = RubyProf.stop
|
419
|
+
printer = RubyProf::GraphPrinter.new(result)
|
420
|
+
printer.print(STDOUT, :min_percent => 2)</pre>
|
424
421
|
|
425
422
|
<p>The first parameter is any writable IO object such as STDOUT or a file. The
|
426
423
|
second parameter, specifies the minimum percentage a method must take to be
|
@@ -438,7 +435,7 @@ directory path and a basename for the files it produces.</p>
|
|
438
435
|
<span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(:<span class="ruby-identifier">path</span> =<span class="ruby-operator">></span> <span class="ruby-string">"."</span>, :<span class="ruby-identifier">profile</span> =<span class="ruby-operator">></span> <span class="ruby-string">"profile"</span>)
|
439
436
|
</pre>
|
440
437
|
|
441
|
-
<h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">¶</a> <a href="#
|
438
|
+
<h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">¶</a> <a href="#top">↑</a></span></h2>
|
442
439
|
|
443
440
|
<p>Depending on the mode and platform, ruby-prof can measure various aspects
|
444
441
|
of a Ruby program. Supported measurements include:</p>
|
@@ -469,8 +466,8 @@ significant CPU or disk time during a profiling run then the reported
|
|
469
466
|
results will be too large.</p>
|
470
467
|
|
471
468
|
<p>CPU time uses the CPU clock counter to measure time. The returned values
|
472
|
-
are dependent on the correctly setting the CPU
|
473
|
-
only supported on Pentium or PowerPC platforms (linux only).</p>
|
469
|
+
are dependent on the correctly setting the CPU's frequency. This mode
|
470
|
+
is only supported on Pentium or PowerPC platforms (linux only).</p>
|
474
471
|
|
475
472
|
<p>Object allocation reports show how many objects each method in a program
|
476
473
|
allocates. This support was added by Sylvain Joyeux and requires a patched
|
@@ -480,13 +477,13 @@ Ruby interpreter. See below.</p>
|
|
480
477
|
This support was added by Alexander Dymo and requires a patched Ruby
|
481
478
|
interpreter. See below.</p>
|
482
479
|
|
483
|
-
<p>Garbage collection runs report how many times Ruby
|
484
|
-
invoked during a profiling session. This support was added by Jeremy
|
480
|
+
<p>Garbage collection runs report how many times Ruby's garbage collector
|
481
|
+
is invoked during a profiling session. This support was added by Jeremy
|
485
482
|
Kemper and requires a patched Ruby interpreter. See below.</p>
|
486
483
|
|
487
|
-
<p>Garbage collection time reports how much time is spent in Ruby
|
488
|
-
collector during a profiling session. This support was added by
|
489
|
-
Kemper and requires a patched Ruby interpreter. See below.</p>
|
484
|
+
<p>Garbage collection time reports how much time is spent in Ruby's
|
485
|
+
garbage collector during a profiling session. This support was added by
|
486
|
+
Jeremy Kemper and requires a patched Ruby interpreter. See below.</p>
|
490
487
|
|
491
488
|
<p>Ruby patches: all of the patches to Ruby are included in the railsexpress
|
492
489
|
patchsets for rvm, see <a
|
@@ -556,7 +553,7 @@ profiling run and is otherwise quiescent.</p>
|
|
556
553
|
|
557
554
|
<p>On both platforms, cpu time is measured using the RDTSC assembly function
|
558
555
|
provided by the Pentium and PowerPC platforms. CPU time is dependent on the
|
559
|
-
cpu
|
556
|
+
cpu's frequency. On Linux, ruby-prof attempts to read this value from
|
560
557
|
“/proc/cpuinfo.” On Windows, you must manually specify the clock
|
561
558
|
frequency. This can be done using the RUBY_PROF_CPU_FREQUENCY environment
|
562
559
|
variable:</p>
|
@@ -567,30 +564,30 @@ variable:</p>
|
|
567
564
|
|
568
565
|
<pre>RubyProf.cpu_frequency = <value></pre>
|
569
566
|
|
570
|
-
<h2 id="label-Multi-threaded+Applications">Multi-threaded Applications<span><a href="#label-Multi-threaded+Applications">¶</a> <a href="#
|
567
|
+
<h2 id="label-Multi-threaded+Applications">Multi-threaded Applications<span><a href="#label-Multi-threaded+Applications">¶</a> <a href="#top">↑</a></span></h2>
|
571
568
|
|
572
569
|
<p>Unfortunately, Ruby does not provide an internal api for detecting thread
|
573
570
|
context switches in 1.8. As a result, the timings ruby-prof reports for
|
574
571
|
each thread may be slightly inaccurate. In particular, this will happen
|
575
572
|
for newly spawned threads that go to sleep immediately (their first call).
|
576
|
-
For instance, if you use Ruby
|
577
|
-
2 seconds will be assigned to the foreground thread and not the newly
|
573
|
+
For instance, if you use Ruby's timeout library to wait for 2 seconds,
|
574
|
+
the 2 seconds will be assigned to the foreground thread and not the newly
|
578
575
|
created background thread. These errors can largely be avoided if the
|
579
576
|
background thread performs any operation before going to sleep.</p>
|
580
577
|
|
581
|
-
<h2 id="label-Performance">Performance<span><a href="#label-Performance">¶</a> <a href="#
|
578
|
+
<h2 id="label-Performance">Performance<span><a href="#label-Performance">¶</a> <a href="#top">↑</a></span></h2>
|
582
579
|
|
583
|
-
<p>Significant effort has been put into reducing ruby-prof
|
584
|
-
as possible. Our tests show that the overhead associated with
|
585
|
-
code varies considerably with the code being profiled. Most
|
586
|
-
run approximately twice as slow while highly recursive
|
587
|
-
fibonacci series test) will run three times slower.</p>
|
580
|
+
<p>Significant effort has been put into reducing ruby-prof's overhead as
|
581
|
+
much as possible. Our tests show that the overhead associated with
|
582
|
+
profiling code varies considerably with the code being profiled. Most
|
583
|
+
programs will run approximately twice as slow while highly recursive
|
584
|
+
programs (like the fibonacci series test) will run three times slower.</p>
|
588
585
|
|
589
|
-
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#
|
586
|
+
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#top">↑</a></span></h2>
|
590
587
|
|
591
588
|
<p>See <a href="LICENSE.html">LICENSE</a> for license information.</p>
|
592
589
|
|
593
|
-
<h2 id="label-Development">Development<span><a href="#label-Development">¶</a> <a href="#
|
590
|
+
<h2 id="label-Development">Development<span><a href="#label-Development">¶</a> <a href="#top">↑</a></span></h2>
|
594
591
|
|
595
592
|
<p>Code is located at <a
|
596
593
|
href="https://github.com/ruby-prof/ruby-prof">github.com/ruby-prof/ruby-prof</a></p>
|
@@ -604,7 +601,7 @@ or start a github issue.</p>
|
|
604
601
|
|
605
602
|
<footer id="validator-badges" role="contentinfo">
|
606
603
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
607
|
-
<p>Generated by <a href="http://
|
608
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-
|
604
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
605
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
609
606
|
</footer>
|
610
607
|
|