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
@@ -6,20 +6,17 @@
6
6
 
7
7
  <title>graph - 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">
@@ -90,7 +87,7 @@
90
87
 
91
88
  <main role="main" aria-label="Page examples/graph.txt">
92
89
 
93
- <h1 id="label-Graph+Profiles">Graph Profiles<span><a href="#label-Graph+Profiles">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
90
+ <h1 id="label-Graph+Profiles">Graph Profiles<span><a href="#label-Graph+Profiles">&para;</a> <a href="#top">&uarr;</a></span></h1>
94
91
 
95
92
  <p>Graph profiles show how long each method runs, which methods call it and
96
93
  which methods it calls.</p>
@@ -191,7 +188,7 @@ which methods it calls.</p>
191
188
  0.00% 0.00% 0.00 0.00 0.00 500 Kernel.rand
192
189
  0.00 0.00 0.00 1/1 Integer#to_int</pre>
193
190
 
194
- <h2 id="label-Overview">Overview<span><a href="#label-Overview">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
191
+ <h2 id="label-Overview">Overview<span><a href="#label-Overview">&para;</a> <a href="#top">&uarr;</a></span></h2>
195
192
 
196
193
  <p>Dashed lines divide the report into entries, with one entry per method.
197
194
  Entries are sorted by total time which is the time spent in the method
@@ -208,7 +205,7 @@ below it are the methods it called (children).</p>
208
205
  %self - The percentage of time spent in this method
209
206
  total - The time spent in this method and its children.
210
207
  self - The time spent in this method.
211
- children - The time spent in this method's children.
208
+ children - The time spent in this method&#39;s children.
212
209
  calls - The number of times this method was called.
213
210
  name - The name of the method.</pre>
214
211
 
@@ -226,7 +223,7 @@ method on a singleton class.</p>
226
223
  its children. Of that time, 4.06 seconds was spent in Integer#upto itself
227
224
  and 4.66 in its children. Overall, Integer#upto was called 501 times.</p>
228
225
 
229
- <h2 id="label-Parents">Parents<span><a href="#label-Parents">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
226
+ <h2 id="label-Parents">Parents<span><a href="#label-Parents">&para;</a> <a href="#top">&uarr;</a></span></h2>
230
227
 
231
228
  <p>In each entry, the lines above the primary line are the methods that
232
229
  called the current method. If the current method is a root method then no
@@ -236,7 +233,7 @@ parents are shown.</p>
236
233
 
237
234
  <pre>total - The time spent in the current method and it children on behalf of the parent method.
238
235
  self - The time spent in this method on behalf of the parent method.
239
- children - The time spent in this method's children on behalf of the parent.
236
+ children - The time spent in this method&#39;s children on behalf of the parent.
240
237
  calls - The number of times the parent method called this child</pre>
241
238
 
242
239
  <p>Looking at Integer#upto again, we see that it was called 500 times from
@@ -244,7 +241,7 @@ Object#is_prime and 1 time from find_largest. Of the 8.72 total seconds
244
241
  spent in Integer#upto, 6.63 were done for Object#is_prime and 2.09 for
245
242
  Object#find_largest.</p>
246
243
 
247
- <h2 id="label-Children">Children<span><a href="#label-Children">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
244
+ <h2 id="label-Children">Children<span><a href="#label-Children">&para;</a> <a href="#top">&uarr;</a></span></h2>
248
245
 
249
246
  <p>In each entry, the lines below the primary line are the methods that the
250
247
  current method called. If the current method is a leaf method then no
@@ -254,7 +251,7 @@ children are shown.</p>
254
251
 
255
252
  <pre>total - The time spent in the child, and its children, on behalf of the current method
256
253
  self - The time spent in the child on behalf of the current method.
257
- children - The time spent in the child's children (ie, granchildren) in behalf of the current method
254
+ children - The time spent in the child&#39;s children (ie, granchildren) in behalf of the current method
258
255
  calls - The number of times the child method was called by the current method.</pre>
259
256
 
260
257
  <p>Taking our example of Integer#upto, we see that it called five other
@@ -271,7 +268,7 @@ in the graph table.</p>
271
268
 
272
269
  <footer id="validator-badges" role="contentinfo">
273
270
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
274
- <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
275
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
271
+ <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
272
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
276
273
  </footer>
277
274
 
data/doc/index.html CHANGED
@@ -6,20 +6,17 @@
6
6
 
7
7
  <title>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">
@@ -78,6 +75,8 @@
78
75
 
79
76
  <ul class="link-list">
80
77
 
78
+ <li><a href="./Rack.html">Rack</a>
79
+
81
80
  <li><a href="./Rack/RubyProf.html">Rack::RubyProf</a>
82
81
 
83
82
  <li><a href="./RubyProf.html">RubyProf</a>
@@ -127,13 +126,13 @@
127
126
  <main role="main">
128
127
 
129
128
 
130
- <h1 id="label-ruby-prof">ruby-prof<span><a href="#label-ruby-prof">&para;</a> <a href="#documentation">&uarr;</a></span></h1>
129
+ <h1 id="label-ruby-prof">ruby-prof<span><a href="#label-ruby-prof">&para;</a> <a href="#top">&uarr;</a></span></h1>
131
130
 
132
131
  <p><a href="https://travis-ci.org/ruby-prof/ruby-prof"><img
133
132
  src="https://travis-ci.org/ruby-prof/ruby-prof.png?branch=master"
134
133
  alt="Build Status" /></a></p>
135
134
 
136
- <h2 id="label-Overview">Overview<span><a href="#label-Overview">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
135
+ <h2 id="label-Overview">Overview<span><a href="#label-Overview">&para;</a> <a href="#top">&uarr;</a></span></h2>
137
136
 
138
137
  <p>ruby-prof is a fast code profiler for Ruby. Its features include:</p>
139
138
  <ul><li>
@@ -161,119 +160,117 @@ href="README_rdoc.html">README</a>.</p>
161
160
  <p>Threads - supports profiling multiple threads simultaneously</p>
162
161
  </li></ul>
163
162
 
164
- <h2 id="label-Requirements">Requirements<span><a href="#label-Requirements">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
163
+ <h2 id="label-Requirements">Requirements<span><a href="#label-Requirements">&para;</a> <a href="#top">&uarr;</a></span></h2>
165
164
 
166
165
  <p>ruby-prof requires Ruby 1.9.3 or higher.</p>
167
166
 
168
- <p>If you are running Linux or Unix youll need a C compiler so the extension
169
- can be compiled when it is installed.</p>
167
+ <p>If you are running Linux or Unix you&#39;ll need a C compiler so the
168
+ extension can be compiled when it is installed.</p>
170
169
 
171
170
  <p>If you are running Windows, then you may need to install the Windows
172
171
  specific RubyGem which includes an already built extension (see Install
173
172
  section).</p>
174
173
 
175
- <h2 id="label-Install">Install<span><a href="#label-Install">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
174
+ <h2 id="label-Install">Install<span><a href="#label-Install">&para;</a> <a href="#top">&uarr;</a></span></h2>
176
175
 
177
176
  <p>The easiest way to install ruby-prof is by using Ruby Gems. To install:</p>
178
177
 
179
- <pre>gem install ruby-prof</pre>
178
+ <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>
179
+ </pre>
180
180
 
181
- <p>If youre on windows then please install the devkit first so that it can
182
- compile.</p>
181
+ <p>If you&#39;re on windows then please install the devkit first so that it
182
+ can compile.</p>
183
183
 
184
- <h2 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
184
+ <h2 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>
185
185
 
186
186
  <p>There are two ways of running ruby-prof, via the command line or via its
187
187
  API.</p>
188
188
 
189
- <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>
189
+ <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>
190
190
 
191
191
  <p>The first is to use ruby-prof to run the Ruby program you want to profile.
192
192
  For more information refer to the documentation of the ruby-prof command.</p>
193
193
 
194
- <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>
194
+ <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>
195
195
 
196
196
  <p>The second way is to use the ruby-prof API to profile particular segments
197
197
  of code.</p>
198
198
 
199
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
199
+ <pre>require &#39;ruby-prof&#39;
200
200
 
201
- <span class="ruby-comment"># Profile the code</span>
202
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
203
- <span class="ruby-operator">...</span>
204
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
205
- <span class="ruby-operator">...</span>
206
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
207
-
208
- <span class="ruby-comment"># Print a flat profile to text</span>
209
- <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>)
210
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>)
211
- </pre>
201
+ # Profile the code
202
+ RubyProf.start
203
+ ...
204
+ [code to profile]
205
+ ...
206
+ result = RubyProf.stop
207
+
208
+ # Print a flat profile to text
209
+ printer = RubyProf::FlatPrinter.new(result)
210
+ printer.print(STDOUT)</pre>
212
211
 
213
212
  <p>Alternatively, you can use a block to tell ruby-prof what to profile:</p>
214
213
 
215
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
214
+ <pre>require &#39;ruby-prof&#39;
216
215
 
217
- <span class="ruby-comment"># Profile the code</span>
218
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
219
- <span class="ruby-operator">...</span>
220
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
221
- <span class="ruby-operator">...</span>
222
- <span class="ruby-keyword">end</span>
216
+ # Profile the code
217
+ result = RubyProf.profile do
218
+ ...
219
+ [code to profile]
220
+ ...
221
+ end
223
222
 
224
- <span class="ruby-comment"># Print a graph profile to text</span>
225
- <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>)
226
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, {})
227
- </pre>
223
+ # Print a graph profile to text
224
+ printer = RubyProf::GraphPrinter.new(result)
225
+ printer.print(STDOUT, {})</pre>
228
226
 
229
227
  <p>ruby-prof also supports pausing and resuming profiling runs.</p>
230
228
 
231
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
229
+ <pre>require &#39;ruby-prof&#39;
232
230
 
233
- <span class="ruby-comment"># Profile the code</span>
234
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
235
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
236
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">pause</span>
237
- [<span class="ruby-identifier">other</span> <span class="ruby-identifier">code</span>]
238
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span>
239
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
240
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
241
- </pre>
231
+ # Profile the code
232
+ RubyProf.start
233
+ [code to profile]
234
+ RubyProf.pause
235
+ [other code]
236
+ RubyProf.resume
237
+ [code to profile]
238
+ result = RubyProf.stop</pre>
242
239
 
243
240
  <p>Note that resume will automatically call start if a profiling run has not
244
241
  yet started. In addition, resume can also take a block:</p>
245
242
 
246
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
243
+ <pre>require &#39;ruby-prof&#39;
247
244
 
248
- <span class="ruby-comment"># Profile the code</span>
249
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span> <span class="ruby-keyword">do</span>
250
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
251
- <span class="ruby-keyword">end</span>
245
+ # Profile the code
246
+ RubyProf.resume do
247
+ [code to profile]
248
+ end
252
249
 
253
- <span class="ruby-identifier">data</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
254
- </pre>
250
+ data = RubyProf.stop</pre>
255
251
 
256
252
  <p>With this usage, resume will automatically call pause at the end of the
257
253
  block.</p>
258
254
 
259
- <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>
255
+ <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>
260
256
 
261
257
  <p>ruby-prof supports eliminating specific methods and threads from profiling
262
258
  results. This is useful for reducing connectivity in the call graph, making
263
259
  it easier to identify the source of performance problems when using a graph
264
260
  printer.</p>
265
261
 
266
- <p>For example, consider Integer#times: its hardly ever useful to know how
267
- much time is spent in the method itself. Were much more interested in how
268
- much the passed in block contributes to the time spent in the method which
269
- contains the Integer#times call.</p>
262
+ <p>For example, consider Integer#times: it&#39;s hardly ever useful to know
263
+ how much time is spent in the method itself. We&#39;re much more interested
264
+ in how much the passed in block contributes to the time spent in the method
265
+ which contains the Integer#times call.</p>
270
266
 
271
267
  <p>Methods are eliminated from the collected data by calling
272
268
  `eliminate_methods!` on the profiling result, before submitting it to a
273
269
  printer.</p>
274
270
 
275
- <pre>result = RubyProf.stop
276
- result.eliminate_methods!([/Integer#times/])</pre>
271
+ <pre class="ruby"><span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
272
+ <span class="ruby-identifier">result</span>.<span class="ruby-identifier">eliminate_methods!</span>([<span class="ruby-node">/Integer#times/</span>])
273
+ </pre>
277
274
 
278
275
  <p>The argument given to `eliminate_methods!` is either an array of regular
279
276
  expressions, or the name of a file containing a list of regular expressions
@@ -285,17 +282,19 @@ those methods had been inlined at their call sites.</p>
285
282
  <p>In a similar manner, threads can be excluded so they are not profiled at
286
283
  all. To do this, pass an array of threads to exclude to ruby-prof:</p>
287
284
 
288
- <pre>RubyProf::exclude_threads = [ thread2 ]
289
- RubyProf.start</pre>
285
+ <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> ]
286
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
287
+ </pre>
290
288
 
291
289
  <p>Note that the excluded threads must be specified <strong>before</strong>
292
290
  profiling.</p>
293
291
 
294
- <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>
292
+ <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>
295
293
 
296
- <p>If you want to get a more accurate measurement of what takes all of a gem’s
297
- bin/xxx command to load, you may want to also measure rubygems’ startup
298
- penalty. You can do this by calling into bin/ruby-prof directly, ex:</p>
294
+ <p>If you want to get a more accurate measurement of what takes all of a
295
+ gem&#39;s bin/xxx command to load, you may want to also measure
296
+ rubygems&#39; startup penalty. You can do this by calling into
297
+ bin/ruby-prof directly, ex:</p>
299
298
 
300
299
  <p>$ gem which ruby-prof</p>
301
300
 
@@ -311,10 +310,10 @@ g:192binsome_installed_gem_command</p>
311
310
  <p>$ ruby g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/bin/ruby-prof
312
311
  ./some_file_that_does_a_require_rubygems_at_the_beginning.rb</p>
313
312
 
314
- <h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
313
+ <h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">&para;</a> <a href="#top">&uarr;</a></span></h2>
315
314
 
316
315
  <p>To profile a Rails application it is vital to run it using production like
317
- settings (cache classes, cache view lookups, etc.). Otherwise, Rails
316
+ settings (cache classes, cache view lookups, etc.). Otherwise, Rail&#39;s
318
317
  dependency loading code will overwhelm any time spent in the application
319
318
  itself (our tests show that Rails dependency loading causes a roughly 6x
320
319
  slowdown). The best way to do this is create a new Rails environment,
@@ -329,15 +328,16 @@ likely turn off caching.</p>
329
328
  </li><li>
330
329
  <p>Add the ruby-prof to your gemfile:</p>
331
330
 
332
- <pre>group :profile do
333
- gem 'ruby-prof'
334
- end</pre>
331
+ <pre class="ruby"><span class="ruby-identifier">group</span> :<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
332
+ <span class="ruby-identifier">gem</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
333
+ <span class="ruby-keyword">end</span>
334
+ </pre>
335
335
  </li><li>
336
336
  <p>Add the ruby prof rack adapter to your middleware stack. One way to do
337
337
  this is by adding the following code to config.ru:</p>
338
338
 
339
339
  <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>
340
- <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>
340
+ <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>
341
341
  <span class="ruby-keyword">end</span>
342
342
  </pre>
343
343
 
@@ -349,7 +349,7 @@ be generated for each request. Note that each request will overwrite the
349
349
  profiling reports created by the previous request!</p>
350
350
  </li></ol>
351
351
 
352
- <h2 id="label-Reports">Reports<span><a href="#label-Reports">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
352
+ <h2 id="label-Reports">Reports<span><a href="#label-Reports">&para;</a> <a href="#top">&uarr;</a></span></h2>
353
353
 
354
354
  <p>ruby-prof can generate a number of different reports:</p>
355
355
  <ul><li>
@@ -399,13 +399,13 @@ href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/call_stack.html
399
399
  <p>Another good example: [<a
400
400
  href="http://twitpic.com/28z94a">twitpic.com/28z94a</a>]</p>
401
401
 
402
- <p>Finally, theres a so called MultiPrinter which can generate several
402
+ <p>Finally, there&#39;s a so called MultiPrinter which can generate several
403
403
  reports in one profiling run. See <a
404
404
  href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/multi.stack.html">examples/multi.stack.html</a>.</p>
405
405
 
406
406
  <p>There is also a graphviz .dot visualiser.</p>
407
407
 
408
- <h2 id="label-Printers">Printers<span><a href="#label-Printers">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
408
+ <h2 id="label-Printers">Printers<span><a href="#label-Printers">&para;</a> <a href="#top">&uarr;</a></span></h2>
409
409
 
410
410
  <p>Reports are created by printers. Supported printers include:</p>
411
411
  <ul><li>
@@ -423,7 +423,7 @@ call graph report in text format</p>
423
423
  Creates a call graph report in HTML (separate files per thread)</p>
424
424
  </li><li>
425
425
  <p><a href="RubyProf/DotPrinter.html">RubyProf::DotPrinter</a> - Creates a
426
- call graph report in GraphViz's DOT format which can be converted to an
426
+ call graph report in GraphViz&#39;s DOT format which can be converted to an
427
427
  image</p>
428
428
  </li><li>
429
429
  <p><a href="RubyProf/CallTreePrinter.html">RubyProf::CallTreePrinter</a> -
@@ -440,11 +440,10 @@ other printers to create several reports in one profiling run</p>
440
440
 
441
441
  <p>To use a printer:</p>
442
442
 
443
- <pre class="ruby"><span class="ruby-operator">...</span>
444
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
445
- <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>)
446
- <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>)
447
- </pre>
443
+ <pre>...
444
+ result = RubyProf.stop
445
+ printer = RubyProf::GraphPrinter.new(result)
446
+ printer.print(STDOUT, :min_percent =&gt; 2)</pre>
448
447
 
449
448
  <p>The first parameter is any writable IO object such as STDOUT or a file. The
450
449
  second parameter, specifies the minimum percentage a method must take to be
@@ -462,7 +461,7 @@ directory path and a basename for the files it produces.</p>
462
461
  <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>)
463
462
  </pre>
464
463
 
465
- <h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
464
+ <h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">&para;</a> <a href="#top">&uarr;</a></span></h2>
466
465
 
467
466
  <p>Depending on the mode and platform, ruby-prof can measure various aspects
468
467
  of a Ruby program. Supported measurements include:</p>
@@ -493,8 +492,8 @@ significant CPU or disk time during a profiling run then the reported
493
492
  results will be too large.</p>
494
493
 
495
494
  <p>CPU time uses the CPU clock counter to measure time. The returned values
496
- are dependent on the correctly setting the CPUs frequency. This mode is
497
- only supported on Pentium or PowerPC platforms (linux only).</p>
495
+ are dependent on the correctly setting the CPU&#39;s frequency. This mode
496
+ is only supported on Pentium or PowerPC platforms (linux only).</p>
498
497
 
499
498
  <p>Object allocation reports show how many objects each method in a program
500
499
  allocates. This support was added by Sylvain Joyeux and requires a patched
@@ -504,13 +503,13 @@ Ruby interpreter. See below.</p>
504
503
  This support was added by Alexander Dymo and requires a patched Ruby
505
504
  interpreter. See below.</p>
506
505
 
507
- <p>Garbage collection runs report how many times Rubys garbage collector is
508
- invoked during a profiling session. This support was added by Jeremy
506
+ <p>Garbage collection runs report how many times Ruby&#39;s garbage collector
507
+ is invoked during a profiling session. This support was added by Jeremy
509
508
  Kemper and requires a patched Ruby interpreter. See below.</p>
510
509
 
511
- <p>Garbage collection time reports how much time is spent in Rubys garbage
512
- collector during a profiling session. This support was added by Jeremy
513
- Kemper and requires a patched Ruby interpreter. See below.</p>
510
+ <p>Garbage collection time reports how much time is spent in Ruby&#39;s
511
+ garbage collector during a profiling session. This support was added by
512
+ Jeremy Kemper and requires a patched Ruby interpreter. See below.</p>
514
513
 
515
514
  <p>Ruby patches: all of the patches to Ruby are included in the railsexpress
516
515
  patchsets for rvm, see <a
@@ -580,7 +579,7 @@ profiling run and is otherwise quiescent.</p>
580
579
 
581
580
  <p>On both platforms, cpu time is measured using the RDTSC assembly function
582
581
  provided by the Pentium and PowerPC platforms. CPU time is dependent on the
583
- cpus frequency. On Linux, ruby-prof attempts to read this value from
582
+ cpu&#39;s frequency. On Linux, ruby-prof attempts to read this value from
584
583
  “/proc/cpuinfo.” On Windows, you must manually specify the clock
585
584
  frequency. This can be done using the RUBY_PROF_CPU_FREQUENCY environment
586
585
  variable:</p>
@@ -591,30 +590,30 @@ variable:</p>
591
590
 
592
591
  <pre>RubyProf.cpu_frequency = &lt;value&gt;</pre>
593
592
 
594
- <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>
593
+ <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>
595
594
 
596
595
  <p>Unfortunately, Ruby does not provide an internal api for detecting thread
597
596
  context switches in 1.8. As a result, the timings ruby-prof reports for
598
597
  each thread may be slightly inaccurate. In particular, this will happen
599
598
  for newly spawned threads that go to sleep immediately (their first call).
600
- For instance, if you use Rubys timeout library to wait for 2 seconds, the
601
- 2 seconds will be assigned to the foreground thread and not the newly
599
+ For instance, if you use Ruby&#39;s timeout library to wait for 2 seconds,
600
+ the 2 seconds will be assigned to the foreground thread and not the newly
602
601
  created background thread. These errors can largely be avoided if the
603
602
  background thread performs any operation before going to sleep.</p>
604
603
 
605
- <h2 id="label-Performance">Performance<span><a href="#label-Performance">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
604
+ <h2 id="label-Performance">Performance<span><a href="#label-Performance">&para;</a> <a href="#top">&uarr;</a></span></h2>
606
605
 
607
- <p>Significant effort has been put into reducing ruby-profs overhead as much
608
- as possible. Our tests show that the overhead associated with profiling
609
- code varies considerably with the code being profiled. Most programs will
610
- run approximately twice as slow while highly recursive programs (like the
611
- fibonacci series test) will run three times slower.</p>
606
+ <p>Significant effort has been put into reducing ruby-prof&#39;s overhead as
607
+ much as possible. Our tests show that the overhead associated with
608
+ profiling code varies considerably with the code being profiled. Most
609
+ programs will run approximately twice as slow while highly recursive
610
+ programs (like the fibonacci series test) will run three times slower.</p>
612
611
 
613
- <h2 id="label-License">License<span><a href="#label-License">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
612
+ <h2 id="label-License">License<span><a href="#label-License">&para;</a> <a href="#top">&uarr;</a></span></h2>
614
613
 
615
614
  <p>See <a href="LICENSE.html">LICENSE</a> for license information.</p>
616
615
 
617
- <h2 id="label-Development">Development<span><a href="#label-Development">&para;</a> <a href="#documentation">&uarr;</a></span></h2>
616
+ <h2 id="label-Development">Development<span><a href="#label-Development">&para;</a> <a href="#top">&uarr;</a></span></h2>
618
617
 
619
618
  <p>Code is located at <a
620
619
  href="https://github.com/ruby-prof/ruby-prof">github.com/ruby-prof/ruby-prof</a></p>
@@ -628,7 +627,7 @@ or start a github issue.</p>
628
627
 
629
628
  <footer id="validator-badges" role="contentinfo">
630
629
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
631
- <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
632
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
630
+ <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
631
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
633
632
  </footer>
634
633