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.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/doc/LICENSE.html +11 -14
  3. data/doc/README_rdoc.html +106 -109
  4. data/doc/Rack.html +6 -9
  5. data/doc/Rack/RubyProf.html +12 -15
  6. data/doc/RubyProf.html +11 -13
  7. data/doc/RubyProf/AbstractPrinter.html +7 -10
  8. data/doc/RubyProf/AggregateCallInfo.html +6 -9
  9. data/doc/RubyProf/CallInfo.html +8 -11
  10. data/doc/RubyProf/CallInfoPrinter.html +7 -10
  11. data/doc/RubyProf/CallInfoVisitor.html +6 -9
  12. data/doc/RubyProf/CallStackPrinter.html +48 -51
  13. data/doc/RubyProf/CallTreePrinter.html +14 -17
  14. data/doc/RubyProf/Cmd.html +44 -47
  15. data/doc/RubyProf/DotPrinter.html +8 -11
  16. data/doc/RubyProf/FlatPrinter.html +6 -9
  17. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +9 -12
  18. data/doc/RubyProf/GraphHtmlPrinter.html +14 -18
  19. data/doc/RubyProf/GraphPrinter.html +6 -9
  20. data/doc/RubyProf/MethodInfo.html +8 -11
  21. data/doc/RubyProf/MultiPrinter.html +6 -9
  22. data/doc/RubyProf/Profile.html +7 -10
  23. data/doc/RubyProf/ProfileTask.html +18 -20
  24. data/doc/RubyProf/Thread.html +6 -9
  25. data/doc/created.rid +4 -4
  26. data/doc/{fonts.css → css/fonts.css} +0 -0
  27. data/doc/{rdoc.css → css/rdoc.css} +11 -1
  28. data/doc/examples/flat_txt.html +8 -11
  29. data/doc/examples/graph_html.html +8 -10
  30. data/doc/examples/graph_txt.html +13 -16
  31. data/doc/index.html +108 -109
  32. data/doc/js/darkfish.js +32 -11
  33. data/doc/js/jquery.js +4 -18
  34. data/doc/js/navigation.js.gz +0 -0
  35. data/doc/js/search_index.js +1 -1
  36. data/doc/js/search_index.js.gz +0 -0
  37. data/doc/js/searcher.js.gz +0 -0
  38. data/doc/table_of_contents.html +9 -9
  39. data/ext/ruby_prof/ruby_prof.c +2 -2
  40. data/lib/ruby-prof/version.rb +1 -1
  41. data/ruby-prof.gemspec +1 -1
  42. data/test/aggregate_test.rb +1 -1
  43. data/test/basic_test.rb +5 -5
  44. data/test/block_test.rb +74 -0
  45. data/test/call_info_test.rb +1 -1
  46. data/test/call_info_visitor_test.rb +1 -1
  47. data/test/duplicate_names_test.rb +1 -1
  48. data/test/dynamic_method_test.rb +37 -56
  49. data/test/enumerable_test.rb +7 -2
  50. data/test/exceptions_test.rb +2 -2
  51. data/test/exclude_threads_test.rb +1 -1
  52. data/test/fiber_test.rb +1 -1
  53. data/test/line_number_test.rb +1 -1
  54. data/test/measure_allocations_test.rb +1 -1
  55. data/test/measure_cpu_time_test.rb +1 -1
  56. data/test/measure_gc_runs_test.rb +1 -1
  57. data/test/measure_gc_time_test.rb +1 -1
  58. data/test/measure_memory_test.rb +2 -2
  59. data/test/measure_process_time_test.rb +1 -1
  60. data/test/measure_wall_time_test.rb +2 -2
  61. data/test/method_elimination_test.rb +1 -1
  62. data/test/module_test.rb +1 -1
  63. data/test/multi_printer_test.rb +1 -1
  64. data/test/pause_resume_test.rb +1 -1
  65. data/test/printers_test.rb +5 -5
  66. data/test/rack_test.rb +2 -2
  67. data/test/recursive_test.rb +1 -1
  68. data/test/singleton_test.rb +1 -1
  69. data/test/stack_printer_test.rb +1 -1
  70. data/test/stack_test.rb +1 -1
  71. data/test/start_stop_test.rb +4 -4
  72. data/test/test_helper.rb +8 -1
  73. data/test/thread_test.rb +1 -1
  74. data/test/unique_call_path_test.rb +2 -2
  75. data/test/yarv_test.rb +1 -1
  76. 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” AND ANY
98
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
99
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
100
- DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
101
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
94
+ <p>THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS “AS IS&#39;&#39;
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://rdoc.rubyforge.org">RDoc</a> 4.1.0.
115
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
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">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
103
+ <h1 id="label-ruby-prof">ruby-prof<span><a href="#label-ruby-prof">&para;</a> <a href="#top">&uarr;</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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
109
+ <h2 id="label-Overview">Overview<span><a href="#label-Overview">&para;</a> <a href="#top">&uarr;</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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
137
+ <h2 id="label-Requirements">Requirements<span><a href="#label-Requirements">&para;</a> <a href="#top">&uarr;</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 youll need a C compiler so the extension
145
- can be compiled when it is installed.</p>
141
+ <p>If you are running Linux or Unix you&#39;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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
148
+ <h2 id="label-Install">Install<span><a href="#label-Install">&para;</a> <a href="#top">&uarr;</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</pre>
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 youre on windows then please install the devkit first so that it can
158
- compile.</p>
155
+ <p>If you&#39;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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
158
+ <h2 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#top">&uarr;</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">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
163
+ <h3 id="label-ruby-prof+executable">ruby-prof executable<span><a href="#label-ruby-prof+executable">&para;</a> <a href="#top">&uarr;</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">&para;</a> <a href="#documentation">&uarr;</a></span></h3>
168
+ <h3 id="label-ruby-prof+API">ruby-prof API<span><a href="#label-ruby-prof+API">&para;</a> <a href="#top">&uarr;</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 class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
173
+ <pre>require &#39;ruby-prof&#39;
176
174
 
177
- <span class="ruby-comment"># Profile the code</span>
178
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
179
- <span class="ruby-operator">...</span>
180
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
181
- <span class="ruby-operator">...</span>
182
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
183
-
184
- <span class="ruby-comment"># Print a flat profile to text</span>
185
- <span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">FlatPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
186
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>)
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 class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
188
+ <pre>require &#39;ruby-prof&#39;
192
189
 
193
- <span class="ruby-comment"># Profile the code</span>
194
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
195
- <span class="ruby-operator">...</span>
196
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
197
- <span class="ruby-operator">...</span>
198
- <span class="ruby-keyword">end</span>
190
+ # Profile the code
191
+ result = RubyProf.profile do
192
+ ...
193
+ [code to profile]
194
+ ...
195
+ end
199
196
 
200
- <span class="ruby-comment"># Print a graph profile to text</span>
201
- <span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GraphPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
202
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, {})
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 class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
203
+ <pre>require &#39;ruby-prof&#39;
208
204
 
209
- <span class="ruby-comment"># Profile the code</span>
210
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
211
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
212
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">pause</span>
213
- [<span class="ruby-identifier">other</span> <span class="ruby-identifier">code</span>]
214
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span>
215
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
216
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
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 class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
217
+ <pre>require &#39;ruby-prof&#39;
223
218
 
224
- <span class="ruby-comment"># Profile the code</span>
225
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span> <span class="ruby-keyword">do</span>
226
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
227
- <span class="ruby-keyword">end</span>
219
+ # Profile the code
220
+ RubyProf.resume do
221
+ [code to profile]
222
+ end
228
223
 
229
- <span class="ruby-identifier">data</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
229
+ <h2 id="label-Method+and+Thread+Elimination">Method and Thread Elimination<span><a href="#label-Method+and+Thread+Elimination">&para;</a> <a href="#top">&uarr;</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: its hardly ever useful to know how
243
- much time is spent in the method itself. Were much more interested in how
244
- much the passed in block contributes to the time spent in the method which
245
- contains the Integer#times call.</p>
236
+ <p>For example, consider Integer#times: it&#39;s hardly ever useful to know
237
+ how much time is spent in the method itself. We&#39;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.stop
252
- result.eliminate_methods!([/Integer#times/])</pre>
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::exclude_threads = [ thread2 ]
265
- RubyProf.start</pre>
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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
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">&para;</a> <a href="#top">&uarr;</a></span></h2>
271
267
 
272
- <p>If you want to get a more accurate measurement of what takes all of a gem’s
273
- bin/xxx command to load, you may want to also measure rubygems’ startup
274
- penalty. You can do this by calling into bin/ruby-prof directly, ex:</p>
268
+ <p>If you want to get a more accurate measurement of what takes all of a
269
+ gem&#39;s bin/xxx command to load, you may want to also measure
270
+ rubygems&#39; 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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
287
+ <h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">&para;</a> <a href="#top">&uarr;</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, Rails
290
+ settings (cache classes, cache view lookups, etc.). Otherwise, Rail&#39;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 :profile do
309
- gem 'ruby-prof'
310
- end</pre>
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">&#39;ruby-prof&#39;</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">&gt;</span> <span class="ruby-string">'/temp/profile'</span>
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">&gt;</span> <span class="ruby-string">&#39;/temp/profile&#39;</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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
326
+ <h2 id="label-Reports">Reports<span><a href="#label-Reports">&para;</a> <a href="#top">&uarr;</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, theres a so called MultiPrinter which can generate several
376
+ <p>Finally, there&#39;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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
382
+ <h2 id="label-Printers">Printers<span><a href="#label-Printers">&para;</a> <a href="#top">&uarr;</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's DOT format which can be converted to an
400
+ call graph report in GraphViz&#39;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 class="ruby"><span class="ruby-operator">...</span>
420
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
421
- <span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GraphPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
422
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, :<span class="ruby-identifier">min_percent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>)
423
- </pre>
417
+ <pre>...
418
+ result = RubyProf.stop
419
+ printer = RubyProf::GraphPrinter.new(result)
420
+ printer.print(STDOUT, :min_percent =&gt; 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">&gt;</span> <span class="ruby-string">&quot;.&quot;</span>, :<span class="ruby-identifier">profile</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;profile&quot;</span>)
439
436
  </pre>
440
437
 
441
- <h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
438
+ <h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">&para;</a> <a href="#top">&uarr;</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 CPUs frequency. This mode is
473
- only supported on Pentium or PowerPC platforms (linux only).</p>
469
+ are dependent on the correctly setting the CPU&#39;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 Rubys garbage collector is
484
- invoked during a profiling session. This support was added by Jeremy
480
+ <p>Garbage collection runs report how many times Ruby&#39;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 Rubys garbage
488
- collector during a profiling session. This support was added by Jeremy
489
- Kemper and requires a patched Ruby interpreter. See below.</p>
484
+ <p>Garbage collection time reports how much time is spent in Ruby&#39;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
- cpus frequency. On Linux, ruby-prof attempts to read this value from
556
+ cpu&#39;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 = &lt;value&gt;</pre>
569
566
 
570
- <h2 id="label-Multi-threaded+Applications">Multi-threaded Applications<span><a href="#label-Multi-threaded+Applications">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
567
+ <h2 id="label-Multi-threaded+Applications">Multi-threaded Applications<span><a href="#label-Multi-threaded+Applications">&para;</a> <a href="#top">&uarr;</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 Rubys timeout library to wait for 2 seconds, the
577
- 2 seconds will be assigned to the foreground thread and not the newly
573
+ For instance, if you use Ruby&#39;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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
578
+ <h2 id="label-Performance">Performance<span><a href="#label-Performance">&para;</a> <a href="#top">&uarr;</a></span></h2>
582
579
 
583
- <p>Significant effort has been put into reducing ruby-profs overhead as much
584
- as possible. Our tests show that the overhead associated with profiling
585
- code varies considerably with the code being profiled. Most programs will
586
- run approximately twice as slow while highly recursive programs (like the
587
- fibonacci series test) will run three times slower.</p>
580
+ <p>Significant effort has been put into reducing ruby-prof&#39;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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
586
+ <h2 id="label-License">License<span><a href="#label-License">&para;</a> <a href="#top">&uarr;</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">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
590
+ <h2 id="label-Development">Development<span><a href="#label-Development">&para;</a> <a href="#top">&uarr;</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://rdoc.rubyforge.org">RDoc</a> 4.1.0.
608
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
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