ruby-prof 0.15.9 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +27 -1
  3. data/README.rdoc +83 -31
  4. data/bin/ruby-prof +4 -4
  5. data/doc/LICENSE.html +1 -1
  6. data/doc/README_rdoc.html +92 -33
  7. data/doc/Rack.html +1 -1
  8. data/doc/Rack/RubyProf.html +17 -14
  9. data/doc/RubyProf.html +30 -29
  10. data/doc/RubyProf/AbstractPrinter.html +1 -1
  11. data/doc/RubyProf/AggregateCallInfo.html +1 -1
  12. data/doc/RubyProf/CallInfo.html +1 -1
  13. data/doc/RubyProf/CallInfoPrinter.html +1 -1
  14. data/doc/RubyProf/CallInfoVisitor.html +1 -1
  15. data/doc/RubyProf/CallStackPrinter.html +1 -1
  16. data/doc/RubyProf/CallTreePrinter.html +349 -67
  17. data/doc/RubyProf/Cmd.html +5 -5
  18. data/doc/RubyProf/DotPrinter.html +2 -2
  19. data/doc/RubyProf/FlatPrinter.html +1 -1
  20. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +1 -1
  21. data/doc/RubyProf/GraphHtmlPrinter.html +1 -1
  22. data/doc/RubyProf/GraphPrinter.html +1 -1
  23. data/doc/RubyProf/MethodInfo.html +2 -2
  24. data/doc/RubyProf/MultiPrinter.html +11 -9
  25. data/doc/RubyProf/Profile.html +94 -44
  26. data/doc/RubyProf/ProfileTask.html +1 -1
  27. data/doc/RubyProf/Thread.html +43 -1
  28. data/doc/created.rid +16 -16
  29. data/doc/examples/flat_txt.html +1 -1
  30. data/doc/examples/graph_html.html +1 -1
  31. data/doc/examples/graph_txt.html +3 -3
  32. data/doc/index.html +85 -30
  33. data/doc/js/navigation.js.gz +0 -0
  34. data/doc/js/search_index.js +1 -1
  35. data/doc/js/search_index.js.gz +0 -0
  36. data/doc/js/searcher.js +2 -2
  37. data/doc/js/searcher.js.gz +0 -0
  38. data/doc/table_of_contents.html +117 -68
  39. data/examples/cachegrind.out.1 +114 -0
  40. data/examples/cachegrind.out.1.32313213 +114 -0
  41. data/examples/graph.txt +1 -1
  42. data/ext/ruby_prof/extconf.rb +6 -2
  43. data/ext/ruby_prof/rp_measure_cpu_time.c +29 -31
  44. data/ext/ruby_prof/rp_method.c +1 -1
  45. data/ext/ruby_prof/rp_thread.c +57 -52
  46. data/ext/ruby_prof/ruby_prof.c +122 -66
  47. data/ext/ruby_prof/ruby_prof.h +2 -0
  48. data/lib/ruby-prof.rb +14 -13
  49. data/lib/ruby-prof/assets/call_stack_printer.js.html +1 -1
  50. data/lib/ruby-prof/compatibility.rb +9 -8
  51. data/lib/ruby-prof/method_info.rb +1 -1
  52. data/lib/ruby-prof/printers/call_tree_printer.rb +88 -50
  53. data/lib/ruby-prof/printers/dot_printer.rb +1 -1
  54. data/lib/ruby-prof/printers/multi_printer.rb +6 -4
  55. data/lib/ruby-prof/profile.rb +0 -1
  56. data/lib/ruby-prof/rack.rb +53 -16
  57. data/lib/ruby-prof/thread.rb +11 -0
  58. data/lib/ruby-prof/version.rb +1 -1
  59. data/test/exclude_threads_test.rb +2 -3
  60. data/test/fiber_test.rb +21 -7
  61. data/test/measure_cpu_time_test.rb +84 -24
  62. data/test/multi_printer_test.rb +5 -4
  63. data/test/pause_resume_test.rb +7 -7
  64. data/test/printers_test.rb +6 -4
  65. data/test/rack_test.rb +26 -1
  66. data/test/test_helper.rb +28 -3
  67. data/test/thread_test.rb +1 -0
  68. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22ff7386396e7f34166a995b4f7a095d172544ef
4
- data.tar.gz: caef497365c65eb46e411f511c9f19e30d5d9502
3
+ metadata.gz: 34157be7a5a12bf59f9a32a87772865ffdfcd4d5
4
+ data.tar.gz: b8e596d1691d4a7c06219fa565f3aa59d4c6c454
5
5
  SHA512:
6
- metadata.gz: 09c37e34272db2c85851224b6ed454919797b3f6d9e9a2059272df0cbe09d4cbb1720b95683228c02966ad97927cf940c1a0c98a64fd77c684315b511915e528
7
- data.tar.gz: 6b2aede7156ff82f4929b6d58e67febc869f933a8ef76948fbc785510e5bb350f69a9c0dbc523c5a4778a15f8de647efaa3f836d86d15939e37b857ad8c52bee
6
+ metadata.gz: 86b2dad68efbc23d8c20d76f030cc9261ad1a6db209319d4eb18e9ad840f7c8c85d4ea08f18dc0855970d8faecbff53ae71282ddf640e9b8840622985f318bc3
7
+ data.tar.gz: f68457fd69407d964b329937f4eb87459fdb1b7a0fffc4a8f64002d6600106bc916f60a73d7edfa2e4c335fb6b44d7a76844793c7ee3f586c837fc162abd9698
data/CHANGES CHANGED
@@ -1,4 +1,30 @@
1
- 0.16.0 (2015-12-08)
1
+ 0.16.0 (2016-08-24)
2
+ =====================
3
+ * ruby-prof can now be installed if ruby has been compiled with --disable-gems or
4
+ RUBYOPT includes --disable-gems (thx to Arthur Nogueira Neves)
5
+ * Profile.new now accepts and prefers an options hash:
6
+ - measure_mode: one of the RubyProf measure mode constants
7
+ - exclude_threads: an array of threads to ignore when collecting profile data
8
+ - include_threads: an array of threads to include when collecting profile data
9
+ - merge_fibers: whether or not to merge the profile data for all fibers under their creating thread
10
+ * overhauled printer for cachegrind profiles:
11
+ - profile data for each thread dumped to a separate file, as kcachegrind does not
12
+ fully implement the cachegrind specification
13
+ - this required a change in interface: it's now necessary to specify a directory
14
+ where to dump the cachegrind files
15
+ - naming convention for cachegrind files changed so that kcachegrind shows them
16
+ all in the open dialog
17
+ * improved Rack middleware:
18
+ - it's now possible to use the MultiPrinter
19
+ - new option ignore_existing_threads: will ignore all prexisiting threads
20
+ when profiling a request, except the thread perfoming the request.
21
+ - new option request_thread_only: will ignore all preexisting threads, but also
22
+ all threads spwaned during the execution of the rack request.
23
+ - new option merge_fibers: whether or not to merge the profile data for all fibers under their creating thread
24
+ * fixed setting threshold bug when displaying stack profiles (thx to Michal Konarski)
25
+ * code related to printing profiles is now autoloaded for efficiency (thx to Dave Gynn)
26
+
27
+ 0.15.9 (2015-12-08)
2
28
  ======================
3
29
  * rack profiler now supports lambdas for generating profile paths (thx to Jean Rougé)
4
30
  * fixed a bug when printing graph profiles
@@ -21,7 +21,7 @@ ruby-prof requires Ruby 1.9.3 or higher. Please note some ruby
21
21
  releases have known bugs which cause ruby-prof problems, like
22
22
  incorrect measurements. We suggest to use the latest minor patch level
23
23
  release if possible. In particular, on the 2.1 branch of ruby you
24
- should use 2.1.7.
24
+ should use at least 2.1.7.
25
25
 
26
26
  If you are running Linux or Unix you'll need a C compiler so the
27
27
  extension can be compiled when it is installed.
@@ -41,20 +41,20 @@ can compile.
41
41
 
42
42
  == Usage
43
43
 
44
- There are two ways of running ruby-prof, via the command line or via
45
- its API.
44
+ There are three major options for running ruby-prof: via the command
45
+ line, via its convenience API or via its core API.
46
46
 
47
- === ruby-prof executable
47
+ === ruby-prof Executable
48
48
 
49
49
  The first is to use ruby-prof to run the Ruby program you want to
50
- profile. For more information refer to the documentation of the
50
+ profile. For more information refer to the documentation of the
51
51
  ruby-prof command.
52
52
 
53
53
 
54
- === ruby-prof API
54
+ === ruby-prof Convenience API
55
55
 
56
- The second way is to use the ruby-prof API to profile particular
57
- segments of code.
56
+ The second way is to use the ruby-prof convenience API to profile
57
+ particular segments of code.
58
58
 
59
59
  require 'ruby-prof'
60
60
 
@@ -95,8 +95,8 @@ ruby-prof also supports pausing and resuming profiling runs.
95
95
  # ... code to profile ...
96
96
  result = RubyProf.stop
97
97
 
98
- Note that resume will automatically call start if a profiling run
99
- has not yet started. In addition, resume can also take a block:
98
+ Note that resume will only work if start has been called previously.
99
+ In addition, resume can also take a block:
100
100
 
101
101
  require 'ruby-prof'
102
102
 
@@ -104,13 +104,56 @@ has not yet started. In addition, resume can also take a block:
104
104
  # ... code to profile...
105
105
  end
106
106
 
107
- data = RubyProf.stop
107
+ result = RubyProf.stop
108
108
 
109
109
  With this usage, resume will automatically call pause at the
110
110
  end of the block.
111
111
 
112
+ === Profiling Selected Threads (Core API)
113
+
114
+ The convenience API does not support running multiple profiles in
115
+ separate threads concurrently, but the RubyProf::Profile API does. In
116
+ fact, the convenience layer uses the Profile API internally. It all
117
+ revolves around Profile objects:
118
+
119
+ RubyProf::Profile.new::
120
+ Create a profile object given an options hash (see below)
121
+
122
+ The following options are available when creating Profile instances:
123
+
124
+ measure_mode::
125
+ One of the defined measure modes
126
+
127
+ exclude_threads::
128
+ Array of threads which should not be profiled.
129
+
130
+ include_threads::
131
+ Array of threads which should be profiled. All other threads will
132
+ be ignored.
133
+
134
+ merge_fibers::
135
+ Whether profiling data for a given thread's fibers should all be
136
+ subsumed under a single entry. Basically only useful to produce
137
+ callgrind profiles.
138
+
139
+ RubyProf::Profile#start::
140
+ Start profiling
141
+
142
+ RubyProf::Profile#pause::
143
+ Pause profiling
144
+
145
+ RubyProf::Profile#resume::
146
+ Resume profiling
147
+
148
+ RubyProf::Profile#stop::
149
+ Stop profiling and return self
112
150
 
113
- == Method and Thread Elimination
151
+ RubyProf::Profile#profile::
152
+ Perform a profile run and return result. Accepts the same arguments
153
+ as RubyProf::Profile.new.
154
+
155
+
156
+ == Method Elimination
114
157
 
115
158
  ruby-prof supports eliminating specific methods and threads from
116
159
  profiling results. This is useful for reducing connectivity in the
@@ -136,13 +179,6 @@ regular expressions (line separated text).
136
179
  After eliminating methods the resulting profile will appear exactly as if those methods
137
180
  had been inlined at their call sites.
138
181
 
139
- In a similar manner, threads can be excluded so they are not profiled at all. To do this,
140
- pass an array of threads to exclude to ruby-prof:
141
-
142
- RubyProf::exclude_threads = [ thread2 ]
143
- RubyProf.start
144
-
145
- Note that the excluded threads must be specified *before* profiling.
146
182
 
147
183
  == Profiling Rails
148
184
 
@@ -158,7 +194,7 @@ So to profile Rails:
158
194
  1. Create a new profile.rb environment. Make sure to turn on
159
195
  <tt>cache_classes</tt> and
160
196
  <tt>cache_template_loading</tt>. Otherwise your profiling results
161
- will be overwhelemed by the time Rails spends loading required
197
+ will be overwhelmed by the time Rails spends loading required
162
198
  files. You should likely turn off caching.
163
199
 
164
200
  2. Add the ruby-prof to your gemfile:
@@ -325,8 +361,17 @@ RubyProf::GC_RUNS::
325
361
  is invoked during a profiling session. This support was added by
326
362
  Jeremy Kemper and requires a patched Ruby interpreter. See below.
327
363
 
364
+ == Patching ruby
365
+
328
366
  All of the patches to Ruby are included in the railsexpress patchsets
329
- for rvm, see https://github.com/skaes/rvm-patchsets
367
+ for rvm, see https://github.com/skaes/rvm-patchsets. You can also use
368
+ these patches manually with other ruby managers (ruby-install,
369
+ ruby-build, etc.).
370
+
371
+ Note if you rebuild your ruby with patches you must uninstall and
372
+ reinstall the ruby-prof gem to take advantage of the new capabilities.
373
+
374
+ == Measure modes
330
375
 
331
376
  To set the measurement:
332
377
 
@@ -371,16 +416,15 @@ otherwise quiescent.
371
416
 
372
417
  == Multi-threaded Applications
373
418
 
374
- Unfortunately, Ruby does not provide an internal API
375
- for detecting thread context switches in 1.8. As a result, the
376
- timings ruby-prof reports for each thread may be slightly
377
- inaccurate. In particular, this will happen for newly
378
- spawned threads that go to sleep immediately (their first call).
379
- For instance, if you use Ruby's timeout library to wait for 2 seconds,
380
- the 2 seconds will be assigned to the foreground thread
381
- and not the newly created background thread. These errors
382
- can largely be avoided if the background thread performs any
383
- operation before going to sleep.
419
+ Unfortunately, Ruby does not provide an internal API for detecting
420
+ thread context switches. As a result, the timings ruby-prof reports
421
+ for each thread may be slightly inaccurate. In particular, this will
422
+ happen for newly spawned threads that go to sleep immediately (their
423
+ first call). For instance, if you use Ruby's timeout library to wait
424
+ for 2 seconds, the 2 seconds will be assigned to the foreground thread
425
+ and not the newly created background thread. These errors can largely
426
+ be avoided if the background thread performs any operation before
427
+ going to sleep.
384
428
 
385
429
  == Performance
386
430
 
@@ -395,6 +439,14 @@ will run three times slower.
395
439
 
396
440
  See LICENSE for license information.
397
441
 
442
+ == API Documentation
443
+
444
+ The ruby-prof API documentation for the latest released gem version
445
+ can be found here: http://www.rubydoc.info/gems/ruby-prof/
446
+
447
+ The ruby-prof API documentation for the master branch is available
448
+ here: http://www.rubydoc.info/github/ruby-prof/ruby-prof/
449
+
398
450
  == Development
399
451
 
400
452
  Code is located at https://github.com/ruby-prof/ruby-prof
@@ -102,8 +102,8 @@ module RubyProf
102
102
  opts.on('--mode=measure_mode',
103
103
  [:process, :wall, :cpu, :allocations, :memory, :gc_runs, :gc_time],
104
104
  'Select what ruby-prof should measure:',
105
- ' process - Process time (default).',
106
- ' wall - Wall time.',
105
+ ' wall - Wall time (default).',
106
+ ' process - Process time.',
107
107
  ' cpu - CPU time (Pentium and PowerPCs only).',
108
108
  ' allocations - Object allocations (requires patched Ruby interpreter).',
109
109
  ' memory - Allocated memory in KB (requires patched Ruby interpreter).',
@@ -111,10 +111,10 @@ module RubyProf
111
111
  ' gc_time - Time spent in garbage collection (requires patched Ruby interpreter).') do |measure_mode|
112
112
 
113
113
  case measure_mode
114
- when :process
115
- options.measure_mode = RubyProf::PROCESS_TIME
116
114
  when :wall
117
115
  options.measure_mode = RubyProf::WALL_TIME
116
+ when :process
117
+ options.measure_mode = RubyProf::PROCESS_TIME
118
118
  when :cpu
119
119
  options.measure_mode = RubyProf::CPU_TIME
120
120
  when :allocations
@@ -108,7 +108,7 @@ DAMAGE.</p>
108
108
 
109
109
  <footer id="validator-badges" role="contentinfo">
110
110
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
111
- <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
111
+ <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
112
112
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
113
113
  </footer>
114
114
 
@@ -60,16 +60,20 @@
60
60
  <li><a href="#label-Requirements">Requirements</a>
61
61
  <li><a href="#label-Install">Install</a>
62
62
  <li><a href="#label-Usage">Usage</a>
63
- <li><a href="#label-ruby-prof+executable">ruby-prof executable</a>
64
- <li><a href="#label-ruby-prof+API">ruby-prof API</a>
65
- <li><a href="#label-Method+and+Thread+Elimination">Method and Thread Elimination</a>
63
+ <li><a href="#label-ruby-prof+Executable">ruby-prof Executable</a>
64
+ <li><a href="#label-ruby-prof+Convenience+API">ruby-prof Convenience API</a>
65
+ <li><a href="#label-Profiling+Selected+Threads+-28Core+API-29">Profiling Selected Threads (Core API)</a>
66
+ <li><a href="#label-Method+Elimination">Method Elimination</a>
66
67
  <li><a href="#label-Profiling+Rails">Profiling Rails</a>
67
68
  <li><a href="#label-Reports">Reports</a>
68
69
  <li><a href="#label-Printers">Printers</a>
69
70
  <li><a href="#label-Measurements">Measurements</a>
71
+ <li><a href="#label-Patching+ruby">Patching ruby</a>
72
+ <li><a href="#label-Measure+modes">Measure modes</a>
70
73
  <li><a href="#label-Multi-threaded+Applications">Multi-threaded Applications</a>
71
74
  <li><a href="#label-Performance">Performance</a>
72
75
  <li><a href="#label-License">License</a>
76
+ <li><a href="#label-API+Documentation">API Documentation</a>
73
77
  <li><a href="#label-Development">Development</a>
74
78
  </ul>
75
79
  </div>
@@ -137,7 +141,8 @@ the KCacheGrind profiling tool.</p>
137
141
  <p>ruby-prof requires Ruby 1.9.3 or higher. Please note some ruby releases
138
142
  have known bugs which cause ruby-prof problems, like incorrect
139
143
  measurements. We suggest to use the latest minor patch level release if
140
- possible. In particular, on the 2.1 branch of ruby you should use 2.1.7.</p>
144
+ possible. In particular, on the 2.1 branch of ruby you should use at least
145
+ 2.1.7.</p>
141
146
 
142
147
  <p>If you are running Linux or Unix you&#39;ll need a C compiler so the
143
148
  extension can be compiled when it is installed.</p>
@@ -158,18 +163,18 @@ can compile.</p>
158
163
 
159
164
  <h2 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>
160
165
 
161
- <p>There are two ways of running ruby-prof, via the command line or via its
162
- API.</p>
166
+ <p>There are three major options for running ruby-prof: via the command line,
167
+ via its convenience API or via its core API.</p>
163
168
 
164
- <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>
169
+ <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>
165
170
 
166
- <p>The first is to use ruby-prof to run the Ruby program you want to profile.
171
+ <p>The first is to use ruby-prof to run the Ruby program you want to profile.
167
172
  For more information refer to the documentation of the ruby-prof command.</p>
168
173
 
169
- <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>
174
+ <h3 id="label-ruby-prof+Convenience+API">ruby-prof Convenience API<span><a href="#label-ruby-prof+Convenience+API">&para;</a> <a href="#top">&uarr;</a></span></h3>
170
175
 
171
- <p>The second way is to use the ruby-prof API to profile particular segments
172
- of code.</p>
176
+ <p>The second way is to use the ruby-prof convenience API to profile
177
+ particular segments of code.</p>
173
178
 
174
179
  <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
175
180
 
@@ -213,8 +218,8 @@ of code.</p>
213
218
  <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
214
219
  </pre>
215
220
 
216
- <p>Note that resume will automatically call start if a profiling run has not
217
- yet started. In addition, resume can also take a block:</p>
221
+ <p>Note that resume will only work if start has been called previously. In
222
+ addition, resume can also take a block:</p>
218
223
 
219
224
  <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
220
225
 
@@ -222,13 +227,59 @@ yet started. In addition, resume can also take a block:</p>
222
227
  <span class="ruby-comment"># ... code to profile...</span>
223
228
  <span class="ruby-keyword">end</span>
224
229
 
225
- <span class="ruby-identifier">data</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
230
+ <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
226
231
  </pre>
227
232
 
228
233
  <p>With this usage, resume will automatically call pause at the end of the
229
234
  block.</p>
230
235
 
231
- <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
+ <h3 id="label-Profiling+Selected+Threads+-28Core+API-29">Profiling Selected Threads (Core API)<span><a href="#label-Profiling+Selected+Threads+-28Core+API-29">&para;</a> <a href="#top">&uarr;</a></span></h3>
237
+
238
+ <p>The convenience API does not support running multiple profiles in separate
239
+ threads concurrently, but the <a
240
+ href="RubyProf/Profile.html">RubyProf::Profile</a> API does. In fact, the
241
+ convenience layer uses the Profile API internally. It all revolves around
242
+ Profile objects:</p>
243
+ <dl class="rdoc-list note-list"><dt><a href="RubyProf/Profile.html#method-c-new">RubyProf::Profile.new</a>
244
+ <dd>
245
+ <p>Create a profile object given an options hash (see below)</p>
246
+
247
+ <p>The following options are available when creating Profile instances:</p>
248
+ <dl class="rdoc-list note-list"><dt>measure_mode
249
+ <dd>
250
+ <p>One of the defined measure modes</p>
251
+ </dd><dt>exclude_threads
252
+ <dd>
253
+ <p>Array of threads which should not be profiled.</p>
254
+ </dd><dt>include_threads
255
+ <dd>
256
+ <p>Array of threads which should be profiled. All other threads will be
257
+ ignored.</p>
258
+ </dd><dt>merge_fibers
259
+ <dd>
260
+ <p>Whether profiling data for a given thread&#39;s fibers should all be
261
+ subsumed under a single entry. Basically only useful to produce callgrind
262
+ profiles.</p>
263
+ </dd></dl>
264
+ </dd><dt><a href="RubyProf/Profile.html#method-i-start">RubyProf::Profile#start</a>
265
+ <dd>
266
+ <p>Start profiling</p>
267
+ </dd><dt><a href="RubyProf/Profile.html#method-i-pause">RubyProf::Profile#pause</a>
268
+ <dd>
269
+ <p>Pause profiling</p>
270
+ </dd><dt><a href="RubyProf/Profile.html#method-i-resume">RubyProf::Profile#resume</a>
271
+ <dd>
272
+ <p>Resume profiling</p>
273
+ </dd><dt><a href="RubyProf/Profile.html#method-i-stop">RubyProf::Profile#stop</a>
274
+ <dd>
275
+ <p>Stop profiling and return self</p>
276
+ </dd><dt>RubyProf::Profile#profile
277
+ <dd>
278
+ <p>Perform a profile run and return result. Accepts the same arguments as <a
279
+ href="RubyProf/Profile.html#method-c-new">RubyProf::Profile.new</a>.</p>
280
+ </dd></dl>
281
+
282
+ <h2 id="label-Method+Elimination">Method Elimination<span><a href="#label-Method+Elimination">&para;</a> <a href="#top">&uarr;</a></span></h2>
232
283
 
233
284
  <p>ruby-prof supports eliminating specific methods and threads from profiling
234
285
  results. This is useful for reducing connectivity in the call graph, making
@@ -255,16 +306,6 @@ expressions (line separated text).</p>
255
306
  <p>After eliminating methods the resulting profile will appear exactly as if
256
307
  those methods had been inlined at their call sites.</p>
257
308
 
258
- <p>In a similar manner, threads can be excluded so they are not profiled at
259
- all. To do this, pass an array of threads to exclude to ruby-prof:</p>
260
-
261
- <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> ]
262
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
263
- </pre>
264
-
265
- <p>Note that the excluded threads must be specified <strong>before</strong>
266
- profiling.</p>
267
-
268
309
  <h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">&para;</a> <a href="#top">&uarr;</a></span></h2>
269
310
 
270
311
  <p>To profile a Rails application it is vital to run it using production like
@@ -278,7 +319,7 @@ profile.rb.</p>
278
319
  <ol><li>
279
320
  <p>Create a new profile.rb environment. Make sure to turn on
280
321
  <code>cache_classes</code> and <code>cache_template_loading</code>.
281
- Otherwise your profiling results will be overwhelemed by the time Rails
322
+ Otherwise your profiling results will be overwhelmed by the time Rails
282
323
  spends loading required files. You should likely turn off caching.</p>
283
324
  </li><li>
284
325
  <p>Add the ruby-prof to your gemfile:</p>
@@ -455,9 +496,18 @@ is invoked during a profiling session. This support was added by Jeremy
455
496
  Kemper and requires a patched Ruby interpreter. See below.</p>
456
497
  </dd></dl>
457
498
 
499
+ <h2 id="label-Patching+ruby">Patching ruby<span><a href="#label-Patching+ruby">&para;</a> <a href="#top">&uarr;</a></span></h2>
500
+
458
501
  <p>All of the patches to Ruby are included in the railsexpress patchsets for
459
502
  rvm, see <a
460
- href="https://github.com/skaes/rvm-patchsets">github.com/skaes/rvm-patchsets</a></p>
503
+ href="https://github.com/skaes/rvm-patchsets">github.com/skaes/rvm-patchsets</a>.
504
+ You can also use these patches manually with other ruby managers
505
+ (ruby-install, ruby-build, etc.).</p>
506
+
507
+ <p>Note if you rebuild your ruby with patches you must uninstall and reinstall
508
+ the ruby-prof gem to take advantage of the new capabilities.</p>
509
+
510
+ <h2 id="label-Measure+modes">Measure modes<span><a href="#label-Measure+modes">&para;</a> <a href="#top">&uarr;</a></span></h2>
461
511
 
462
512
  <p>To set the measurement:</p>
463
513
 
@@ -504,11 +554,11 @@ profiling run and is otherwise quiescent.</p>
504
554
  <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>
505
555
 
506
556
  <p>Unfortunately, Ruby does not provide an internal API for detecting thread
507
- context switches in 1.8. As a result, the timings ruby-prof reports for
508
- each thread may be slightly inaccurate. In particular, this will happen
509
- for newly spawned threads that go to sleep immediately (their first call).
510
- For instance, if you use Ruby&#39;s timeout library to wait for 2 seconds,
511
- the 2 seconds will be assigned to the foreground thread and not the newly
557
+ context switches. As a result, the timings ruby-prof reports for each
558
+ thread may be slightly inaccurate. In particular, this will happen for
559
+ newly spawned threads that go to sleep immediately (their first call). For
560
+ instance, if you use Ruby&#39;s timeout library to wait for 2 seconds, the
561
+ 2 seconds will be assigned to the foreground thread and not the newly
512
562
  created background thread. These errors can largely be avoided if the
513
563
  background thread performs any operation before going to sleep.</p>
514
564
 
@@ -524,6 +574,15 @@ programs (like the fibonacci series test) will run three times slower.</p>
524
574
 
525
575
  <p>See <a href="LICENSE.html">LICENSE</a> for license information.</p>
526
576
 
577
+ <h2 id="label-API+Documentation">API Documentation<span><a href="#label-API+Documentation">&para;</a> <a href="#top">&uarr;</a></span></h2>
578
+
579
+ <p>The ruby-prof API documentation for the latest released gem version can be
580
+ found here: <a
581
+ href="http://www.rubydoc.info/gems/ruby-prof">www.rubydoc.info/gems/ruby-prof</a>/</p>
582
+
583
+ <p>The ruby-prof API documentation for the master branch is available here: <a
584
+ href="http://www.rubydoc.info/github/ruby-prof/ruby-prof">www.rubydoc.info/github/ruby-prof/ruby-prof</a>/</p>
585
+
527
586
  <h2 id="label-Development">Development<span><a href="#label-Development">&para;</a> <a href="#top">&uarr;</a></span></h2>
528
587
 
529
588
  <p>Code is located at <a
@@ -538,7 +597,7 @@ or open a github issue.</p>
538
597
 
539
598
  <footer id="validator-badges" role="contentinfo">
540
599
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
541
- <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
600
+ <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
542
601
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
543
602
  </footer>
544
603