ruby-prof 0.16.2 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +15 -0
  3. data/README.rdoc +36 -5
  4. data/bin/ruby-prof +7 -2
  5. data/doc/LICENSE.html +2 -1
  6. data/doc/README_rdoc.html +42 -8
  7. data/doc/Rack.html +2 -1
  8. data/doc/Rack/RubyProf.html +25 -18
  9. data/doc/Rack/RubyProf/RackProfiler.html +343 -0
  10. data/doc/RubyProf.html +14 -2
  11. data/doc/RubyProf/AbstractPrinter.html +91 -12
  12. data/doc/RubyProf/AggregateCallInfo.html +2 -1
  13. data/doc/RubyProf/CallInfo.html +18 -78
  14. data/doc/RubyProf/CallInfoPrinter.html +2 -1
  15. data/doc/RubyProf/CallInfoVisitor.html +2 -1
  16. data/doc/RubyProf/CallStackPrinter.html +35 -29
  17. data/doc/RubyProf/CallTreePrinter.html +98 -14
  18. data/doc/RubyProf/Cmd.html +11 -5
  19. data/doc/RubyProf/DeprecationWarnings.html +148 -0
  20. data/doc/RubyProf/DotPrinter.html +2 -1
  21. data/doc/RubyProf/FlatPrinter.html +2 -1
  22. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +7 -5
  23. data/doc/RubyProf/GraphHtmlPrinter.html +18 -12
  24. data/doc/RubyProf/GraphPrinter.html +2 -1
  25. data/doc/RubyProf/MethodInfo.html +19 -88
  26. data/doc/RubyProf/MultiPrinter.html +231 -17
  27. data/doc/RubyProf/Profile.html +184 -39
  28. data/doc/RubyProf/Profile/ExcludeCommonMethods.html +411 -0
  29. data/doc/RubyProf/Profile/LegacyMethodElimination.html +158 -0
  30. data/doc/RubyProf/ProfileTask.html +2 -1
  31. data/doc/RubyProf/Thread.html +4 -39
  32. data/doc/created.rid +21 -19
  33. data/doc/css/fonts.css +6 -6
  34. data/doc/examples/flat_txt.html +2 -1
  35. data/doc/examples/graph_html.html +2 -1
  36. data/doc/examples/graph_txt.html +2 -1
  37. data/doc/index.html +47 -7
  38. data/doc/js/darkfish.js +7 -7
  39. data/doc/js/search_index.js +1 -1
  40. data/doc/js/search_index.js.gz +0 -0
  41. data/doc/js/searcher.js +1 -0
  42. data/doc/js/searcher.js.gz +0 -0
  43. data/doc/table_of_contents.html +190 -80
  44. data/ext/ruby_prof/extconf.rb +4 -0
  45. data/ext/ruby_prof/rp_call_info.c +19 -1
  46. data/ext/ruby_prof/rp_call_info.h +8 -3
  47. data/ext/ruby_prof/rp_method.c +282 -57
  48. data/ext/ruby_prof/rp_method.h +28 -5
  49. data/ext/ruby_prof/rp_stack.c +69 -24
  50. data/ext/ruby_prof/rp_stack.h +21 -9
  51. data/ext/ruby_prof/rp_thread.c +4 -1
  52. data/ext/ruby_prof/ruby_prof.c +142 -39
  53. data/ext/ruby_prof/ruby_prof.h +3 -0
  54. data/lib/ruby-prof.rb +10 -0
  55. data/lib/ruby-prof/call_info.rb +0 -11
  56. data/lib/ruby-prof/method_info.rb +4 -12
  57. data/lib/ruby-prof/printers/abstract_printer.rb +19 -1
  58. data/lib/ruby-prof/printers/call_info_printer.rb +1 -1
  59. data/lib/ruby-prof/printers/call_stack_printer.rb +9 -4
  60. data/lib/ruby-prof/printers/call_tree_printer.rb +15 -2
  61. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +23 -4
  62. data/lib/ruby-prof/printers/graph_html_printer.rb +10 -5
  63. data/lib/ruby-prof/printers/graph_printer.rb +2 -2
  64. data/lib/ruby-prof/printers/multi_printer.rb +44 -18
  65. data/lib/ruby-prof/profile.rb +13 -42
  66. data/lib/ruby-prof/profile/exclude_common_methods.rb +201 -0
  67. data/lib/ruby-prof/profile/legacy_method_elimination.rb +49 -0
  68. data/lib/ruby-prof/rack.rb +130 -51
  69. data/lib/ruby-prof/thread.rb +0 -6
  70. data/lib/ruby-prof/version.rb +1 -1
  71. data/ruby-prof.gemspec +4 -3
  72. data/test/aggregate_test.rb +1 -1
  73. data/test/exclude_methods_test.rb +146 -0
  74. data/test/line_number_test.rb +12 -3
  75. data/test/multi_printer_test.rb +23 -2
  76. data/test/no_method_class_test.rb +1 -1
  77. data/test/printers_test.rb +21 -1
  78. data/test/rack_test.rb +64 -0
  79. data/test/recursive_test.rb +15 -15
  80. data/test/test_helper.rb +11 -0
  81. metadata +20 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 998f8b9ded9813ff8861c7a4fb23aaf5bd71ce92
4
- data.tar.gz: a72b21161e6538935337a6321361449592663a66
3
+ metadata.gz: 94e9eba05612bbd737798359bcf898e176123b9d
4
+ data.tar.gz: 6847861b3f77dc3fb2debd860d5c7ea98c9ffd5d
5
5
  SHA512:
6
- metadata.gz: 61004f65fda9b55bc3eb68ade93060c5ae1d074215c44b94500517ea18704c7b40942d705cdd07b0bdc3a830e8ea3a3ff47af43873057769f8dcc3ecfddf4d38
7
- data.tar.gz: 06208b57ce6d33668f5210a5c19869e0e434ab9933ce657b455adea1d8167868439976fbdb76dcf9da157f774c7744af786324405bfe85202475d7b7d6fb07ff
6
+ metadata.gz: e36f147192ce9457a88baeaec6c28702d33fd1316307697d720b1f1531eefc85362a27b715b806aa41e8dce76aeeb994583a5078f14c554c234905eea8cfd338
7
+ data.tar.gz: fea5bf49e7b6d00ac22d54d5f7852dab1726e88595a3e188e8352934f82e66e97f9780e811bfc073e52c3fba256693a0d9cb34892356b9cf048216001ba1b6c3
data/CHANGES CHANGED
@@ -1,3 +1,18 @@
1
+ 0.17.0 (2017-12-17)
2
+ =====================
3
+ * Changed method/class names produced by the callgrind printer to be more kcachegrind
4
+ friendly (thx to Nelson Gauthier and Ben Hughes, see https://github.com/ruby-prof/ruby-prof/pull/200).
5
+ * Recursive instances of a method call are now dtected during profiling (thx to Nelson Gauthier and
6
+ Ben Hughes, see https://github.com/ruby-prof/ruby-prof/pull/201).
7
+ * Methods can now be ignored during a profiling run instead of eliminating them
8
+ after a profile run, which has been deprecated (thx to Nelson Gauthier and Ben Hughes,
9
+ see https://github.com/ruby-prof/ruby-prof/pull/202).
10
+ * Use RUBY_PROF_EDITOR_URI=emacs to open source code links in the one true editor.
11
+ (thx Alexander Egorov, see https://github.com/ruby-prof/ruby-prof/pull/183 and
12
+ https://github.com/typester/emacs-handler).
13
+ * Fixed that calling profile.stop would stop profiling all active profiling runs.
14
+ * Fixed that remembering parent call frame pointer before stack reallocation could cause a segfault.
15
+
1
16
  0.16.2 (2016-08-25)
2
17
  =====================
3
18
  * fixed incorrect setting of RUBY_VERSION macro
@@ -48,7 +48,7 @@ line, via its convenience API or via its core API.
48
48
 
49
49
  The first is to use ruby-prof to run the Ruby program you want to
50
50
  profile. For more information refer to the documentation of the
51
- ruby-prof command.
51
+ ruby-prof command: `$ ruby-prof -h.`
52
52
 
53
53
 
54
54
  === ruby-prof Convenience API
@@ -153,7 +153,7 @@ RubyProf::Profile#profile::
153
153
  as RubyProf::Profile.new.
154
154
 
155
155
 
156
- == Method Elimination
156
+ == Method Elimination (Deprecated)
157
157
 
158
158
  ruby-prof supports eliminating specific methods and threads from
159
159
  profiling results. This is useful for reducing connectivity in the
@@ -180,6 +180,27 @@ After eliminating methods the resulting profile will appear exactly as if those
180
180
  had been inlined at their call sites.
181
181
 
182
182
 
183
+ == Method Exclusion
184
+
185
+ ruby-prof supports exluding methods from profiling. The effect on
186
+ collected metrics are identical to eliminating methods from the
187
+ profiling result in a prost process step. The interface is slightly
188
+ different though:
189
+
190
+ profile = RubyProf.new(...)
191
+ profile.exclude_methods!(Integer, :times, ...)
192
+ profile.start
193
+
194
+ A convenience method is provided to exclude a large number of methods
195
+ which usually clutter up profiles:
196
+
197
+ profile.exclude_common_methods!
198
+
199
+ However, this is a somewhat opinionated method collection. It's
200
+ usually better to view it as an inspiration instead of using it
201
+ directly (see https://github.com/ruby-prof/ruby-prof/blob/e087b7d7ca11eecf1717d95a5c5fea1e36ea3136/lib/ruby-prof/profile/exclude_common_methods.rb).
202
+
203
+
183
204
  == Profiling Rails
184
205
 
185
206
  To profile a Rails application it is vital to run it using production like
@@ -295,7 +316,7 @@ RubyProf::CallStackPrinter::
295
316
  RubyProf::MultiPrinter::
296
317
  Uses the other printers to create several reports in one profiling run
297
318
 
298
- To use a printer:
319
+ Most printers are used in the following way:
299
320
 
300
321
  result = RubyProf.stop
301
322
  printer = RubyProf::GraphPrinter.new(result)
@@ -311,12 +332,15 @@ documentation for the different printers.
311
332
  The other option is <tt>:print_file => true</tt> (default false),
312
333
  which adds the filename to the output (GraphPrinter only).
313
334
 
314
- <tt>MultiPrinter</tt> differs from the other printers in that it
315
- requires a directory path and a basename for the files it produces.
335
+ <tt>MultiPrinter</tt> and <tt>CallTreePrinter</tt>differ from the
336
+ other printers in that they require a directory path and a profile
337
+ basename for the files they produce:
316
338
 
317
339
  printer = RubyProf::MultiPrinter.new(result)
318
340
  printer.print(:path => ".", :profile => "profile")
319
341
 
342
+ The values given in the example above are the defaults.
343
+
320
344
  == Measurements
321
345
 
322
346
  Depending on the mode and platform, ruby-prof can measure various
@@ -435,6 +459,13 @@ profiled. Most programs will run approximately twice as slow
435
459
  while highly recursive programs (like the fibonacci series test)
436
460
  will run three times slower.
437
461
 
462
+ == Editing links
463
+
464
+ Use <tt>RUBY_PROF_EDITOR_URI</tt> environment variable to open source
465
+ code files in your favorite text editor. For example,
466
+ <tt>RUBY_PROF_EDITOR_URI=atm</tt> will produce links for Atom text
467
+ editor.
468
+
438
469
  == License
439
470
 
440
471
  See LICENSE for license information.
@@ -250,9 +250,14 @@ module RubyProf
250
250
 
251
251
  self.option_parser.parse! ARGV
252
252
 
253
- if options.printer == RubyProf::MultiPrinter
253
+ if options.printer.needs_dir?
254
254
  options.file ||= "."
255
255
  options.old_wd ||= Dir.pwd
256
+ if !File.directory?(options.file)
257
+ puts "'#{options.file}' is not a directory"
258
+ puts "#{options.printer} needs an existing directory path to put profiles under."
259
+ exit(-1)
260
+ end
256
261
  end
257
262
  rescue OptionParser::InvalidOption, OptionParser::InvalidArgument, OptionParser::MissingArgument => e
258
263
  puts self.option_parser
@@ -322,7 +327,7 @@ at_exit {
322
327
  if cmd.options.file
323
328
  # write it relative to the dir they *started* in, as it's a bit surprising to write it in the dir they end up in.
324
329
  Dir.chdir(cmd.options.old_wd) do
325
- if printer.is_a?(RubyProf::MultiPrinter)
330
+ if printer.class.needs_dir?
326
331
  printer.print(printer_options.merge(:path => cmd.options.file))
327
332
  else
328
333
  File.open(cmd.options.file, 'w') do |file|
@@ -8,6 +8,7 @@
8
8
 
9
9
  <script type="text/javascript">
10
10
  var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
11
12
  </script>
12
13
 
13
14
  <script src="./js/jquery.js"></script>
@@ -108,7 +109,7 @@ DAMAGE.</p>
108
109
 
109
110
  <footer id="validator-badges" role="contentinfo">
110
111
  <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.2.
112
+ <p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
112
113
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
113
114
  </footer>
114
115
 
@@ -8,6 +8,7 @@
8
8
 
9
9
  <script type="text/javascript">
10
10
  var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
11
12
  </script>
12
13
 
13
14
  <script src="./js/jquery.js"></script>
@@ -63,7 +64,8 @@
63
64
  <li><a href="#label-ruby-prof+Executable">ruby-prof Executable</a>
64
65
  <li><a href="#label-ruby-prof+Convenience+API">ruby-prof Convenience API</a>
65
66
  <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>
67
+ <li><a href="#label-Method+Elimination+-28Deprecated-29">Method Elimination (Deprecated)</a>
68
+ <li><a href="#label-Method+Exclusion">Method Exclusion</a>
67
69
  <li><a href="#label-Profiling+Rails">Profiling Rails</a>
68
70
  <li><a href="#label-Reports">Reports</a>
69
71
  <li><a href="#label-Printers">Printers</a>
@@ -72,6 +74,7 @@
72
74
  <li><a href="#label-Measure+modes">Measure modes</a>
73
75
  <li><a href="#label-Multi-threaded+Applications">Multi-threaded Applications</a>
74
76
  <li><a href="#label-Performance">Performance</a>
77
+ <li><a href="#label-Editing+links">Editing links</a>
75
78
  <li><a href="#label-License">License</a>
76
79
  <li><a href="#label-API+Documentation">API Documentation</a>
77
80
  <li><a href="#label-Development">Development</a>
@@ -169,7 +172,8 @@ via its convenience API or via its core API.</p>
169
172
  <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>
170
173
 
171
174
  <p>The first is to use ruby-prof to run the Ruby program you want to profile.
172
- For more information refer to the documentation of the ruby-prof command.</p>
175
+ For more information refer to the documentation of the ruby-prof command:
176
+ `$ ruby-prof -h.`</p>
173
177
 
174
178
  <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>
175
179
 
@@ -273,13 +277,13 @@ profiles.</p>
273
277
  </dd><dt><a href="RubyProf/Profile.html#method-i-stop">RubyProf::Profile#stop</a>
274
278
  <dd>
275
279
  <p>Stop profiling and return self</p>
276
- </dd><dt>RubyProf::Profile#profile
280
+ </dd><dt><a href="RubyProf/Profile.html#method-i-profile">RubyProf::Profile#profile</a>
277
281
  <dd>
278
282
  <p>Perform a profile run and return result. Accepts the same arguments as <a
279
283
  href="RubyProf/Profile.html#method-c-new">RubyProf::Profile.new</a>.</p>
280
284
  </dd></dl>
281
285
 
282
- <h2 id="label-Method+Elimination">Method Elimination<span><a href="#label-Method+Elimination">&para;</a> <a href="#top">&uarr;</a></span></h2>
286
+ <h2 id="label-Method+Elimination+-28Deprecated-29">Method Elimination (Deprecated)<span><a href="#label-Method+Elimination+-28Deprecated-29">&para;</a> <a href="#top">&uarr;</a></span></h2>
283
287
 
284
288
  <p>ruby-prof supports eliminating specific methods and threads from profiling
285
289
  results. This is useful for reducing connectivity in the call graph, making
@@ -306,6 +310,26 @@ expressions (line separated text).</p>
306
310
  <p>After eliminating methods the resulting profile will appear exactly as if
307
311
  those methods had been inlined at their call sites.</p>
308
312
 
313
+ <h2 id="label-Method+Exclusion">Method Exclusion<span><a href="#label-Method+Exclusion">&para;</a> <a href="#top">&uarr;</a></span></h2>
314
+
315
+ <p>ruby-prof supports exluding methods from profiling. The effect on collected
316
+ metrics are identical to eliminating methods from the profiling result in a
317
+ prost process step. The interface is slightly different though:</p>
318
+
319
+ <pre>profile = RubyProf.new(...)
320
+ profile.exclude_methods!(Integer, :times, ...)
321
+ profile.start</pre>
322
+
323
+ <p>A convenience method is provided to exclude a large number of methods which
324
+ usually clutter up profiles:</p>
325
+
326
+ <pre class="ruby"><span class="ruby-identifier">profile</span>.<span class="ruby-identifier">exclude_common_methods!</span>
327
+ </pre>
328
+
329
+ <p>However, this is a somewhat opinionated method collection. It&#39;s usually
330
+ better to view it as an inspiration instead of using it directly (see <a
331
+ href="https://github.com/ruby-prof/ruby-prof/blob/e087b7d7ca11eecf1717d95a5c5fea1e36ea3136/lib/ruby-prof/profile/exclude_common_methods.rb">github.com/ruby-prof/ruby-prof/blob/e087b7d7ca11eecf1717d95a5c5fea1e36ea3136/lib/ruby-prof/profile/exclude_common_methods.rb</a>).</p>
332
+
309
333
  <h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">&para;</a> <a href="#top">&uarr;</a></span></h2>
310
334
 
311
335
  <p>To profile a Rails application it is vital to run it using production like
@@ -431,7 +455,7 @@ converted to an image</p>
431
455
  <p>Uses the other printers to create several reports in one profiling run</p>
432
456
  </dd></dl>
433
457
 
434
- <p>To use a printer:</p>
458
+ <p>Most printers are used in the following way:</p>
435
459
 
436
460
  <pre class="ruby"><span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
437
461
  <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>)
@@ -447,13 +471,16 @@ the different printers.</p>
447
471
  <p>The other option is <code>:print_file =&gt; true</code> (default false),
448
472
  which adds the filename to the output (GraphPrinter only).</p>
449
473
 
450
- <p><code>MultiPrinter</code> differs from the other printers in that it
451
- requires a directory path and a basename for the files it produces.</p>
474
+ <p><code>MultiPrinter</code> and <code>CallTreePrinter</code>differ from the
475
+ other printers in that they require a directory path and a profile basename
476
+ for the files they produce:</p>
452
477
 
453
478
  <pre class="ruby"><span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">MultiPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
454
479
  <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>)
455
480
  </pre>
456
481
 
482
+ <p>The values given in the example above are the defaults.</p>
483
+
457
484
  <h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">&para;</a> <a href="#top">&uarr;</a></span></h2>
458
485
 
459
486
  <p>Depending on the mode and platform, ruby-prof can measure various aspects
@@ -570,6 +597,13 @@ profiling code varies considerably with the code being profiled. Most
570
597
  programs will run approximately twice as slow while highly recursive
571
598
  programs (like the fibonacci series test) will run three times slower.</p>
572
599
 
600
+ <h2 id="label-Editing+links">Editing links<span><a href="#label-Editing+links">&para;</a> <a href="#top">&uarr;</a></span></h2>
601
+
602
+ <p>Use <code>RUBY_PROF_EDITOR_URI</code> environment variable to open source
603
+ code files in your favorite text editor. For example,
604
+ <code>RUBY_PROF_EDITOR_URI=atm</code> will produce links for Atom text
605
+ editor.</p>
606
+
573
607
  <h2 id="label-License">License<span><a href="#label-License">&para;</a> <a href="#top">&uarr;</a></span></h2>
574
608
 
575
609
  <p>See <a href="LICENSE.html">LICENSE</a> for license information.</p>
@@ -597,7 +631,7 @@ or open a github issue.</p>
597
631
 
598
632
  <footer id="validator-badges" role="contentinfo">
599
633
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
600
- <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
634
+ <p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
601
635
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
602
636
  </footer>
603
637
 
@@ -8,6 +8,7 @@
8
8
 
9
9
  <script type="text/javascript">
10
10
  var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
11
12
  </script>
12
13
 
13
14
  <script src="./js/jquery.js"></script>
@@ -89,7 +90,7 @@
89
90
 
90
91
  <footer id="validator-badges" role="contentinfo">
91
92
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
92
- <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
93
+ <p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
93
94
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
94
95
  </footer>
95
96
 
@@ -8,6 +8,7 @@
8
8
 
9
9
  <script type="text/javascript">
10
10
  var rdoc_rel_prefix = "../";
11
+ var index_rel_prefix = "../";
11
12
  </script>
12
13
 
13
14
  <script src="../js/jquery.js"></script>
@@ -130,19 +131,18 @@
130
131
  <pre><span class="ruby-comment"># File lib/ruby-prof/rack.rb, line 5</span>
131
132
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">options</span> = {})
132
133
  <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
133
- <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
134
- <span class="ruby-ivar">@options</span>[<span class="ruby-value">:min_percent</span>] <span class="ruby-operator">||=</span> <span class="ruby-value">1</span>
135
134
 
136
- <span class="ruby-ivar">@tmpdir</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:path</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>
137
- <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-ivar">@tmpdir</span>)
135
+ <span class="ruby-identifier">options</span>[<span class="ruby-value">:min_percent</span>] <span class="ruby-operator">||=</span> <span class="ruby-value">1</span>
138
136
 
139
- <span class="ruby-ivar">@printer_klasses</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-value">:printers</span>] <span class="ruby-operator">||</span> {<span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">FlatPrinter</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;flat.txt&#39;</span>,
140
- <span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GraphPrinter</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;graph.txt&#39;</span>,
141
- <span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GraphHtmlPrinter</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;graph.html&#39;</span>,
142
- <span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">CallStackPrinter</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;call_stack.html&#39;</span>}
137
+ <span class="ruby-identifier">options</span>[<span class="ruby-value">:path</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>
138
+ <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:path</span>])
143
139
 
144
140
  <span class="ruby-ivar">@skip_paths</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:skip_paths</span>] <span class="ruby-operator">||</span> [<span class="ruby-regexp">%r{^/assets}</span>, <span class="ruby-regexp">%r{\.(css|js|png|jpeg|jpg|gif)$}</span>]
145
141
  <span class="ruby-ivar">@only_paths</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:only_paths</span>]
142
+
143
+ <span class="ruby-ivar">@max_requests</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:max_requests</span>]
144
+
145
+ <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
146
146
  <span class="ruby-keyword">end</span></pre>
147
147
  </div>
148
148
 
@@ -181,23 +181,30 @@
181
181
 
182
182
 
183
183
  <div class="method-source-code" id="call-source">
184
- <pre><span class="ruby-comment"># File lib/ruby-prof/rack.rb, line 22</span>
184
+ <pre><span class="ruby-comment"># File lib/ruby-prof/rack.rb, line 21</span>
185
185
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
186
186
  <span class="ruby-identifier">request</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">env</span>)
187
187
 
188
188
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">should_profile?</span>(<span class="ruby-identifier">request</span>.<span class="ruby-identifier">path</span>)
189
+ <span class="ruby-identifier">profiler</span>.<span class="ruby-identifier">resume</span>
189
190
  <span class="ruby-keyword">begin</span>
190
- <span class="ruby-identifier">result</span> = <span class="ruby-keyword">nil</span>
191
- <span class="ruby-identifier">data</span> = <span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">Profile</span>.<span class="ruby-identifier">profile</span>(<span class="ruby-identifier">profiling_options</span>) <span class="ruby-keyword">do</span>
192
- <span class="ruby-identifier">result</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
193
- <span class="ruby-keyword">end</span>
191
+ <span class="ruby-identifier">result</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
192
+ <span class="ruby-keyword">ensure</span>
193
+ <span class="ruby-identifier">profiler</span>.<span class="ruby-identifier">pause</span>
194
+ <span class="ruby-keyword">end</span>
194
195
 
195
- <span class="ruby-identifier">path</span> = <span class="ruby-identifier">request</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">&#39;/&#39;</span>, <span class="ruby-string">&#39;-&#39;</span>)
196
- <span class="ruby-identifier">path</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">0</span>)
196
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">profiler</span>.<span class="ruby-identifier">max_requests_reached?</span>
197
+ <span class="ruby-identifier">prefix</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">aggregate_requests?</span>
198
+ <span class="ruby-keyword">nil</span>
199
+ <span class="ruby-keyword">else</span>
200
+ <span class="ruby-identifier">request</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">&#39;/&#39;</span>, <span class="ruby-string">&#39;-&#39;</span>)[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
201
+ <span class="ruby-keyword">end</span>
197
202
 
198
- <span class="ruby-identifier">print</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">path</span>)
199
- <span class="ruby-identifier">result</span>
203
+ <span class="ruby-identifier">profiler</span>.<span class="ruby-identifier">print!</span>(<span class="ruby-identifier">prefix</span>)
204
+ <span class="ruby-identifier">delete_profiler!</span>
200
205
  <span class="ruby-keyword">end</span>
206
+
207
+ <span class="ruby-identifier">result</span>
201
208
  <span class="ruby-keyword">else</span>
202
209
  <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
203
210
  <span class="ruby-keyword">end</span>
@@ -220,7 +227,7 @@
220
227
 
221
228
  <footer id="validator-badges" role="contentinfo">
222
229
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
223
- <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
230
+ <p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
224
231
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
225
232
  </footer>
226
233
 
@@ -0,0 +1,343 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Rack::RubyProf::RackProfiler - ruby-prof</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "../../";
11
+ var index_rel_prefix = "../../";
12
+ </script>
13
+
14
+ <script src="../../js/jquery.js"></script>
15
+ <script src="../../js/darkfish.js"></script>
16
+
17
+ <link href="../../css/fonts.css" rel="stylesheet">
18
+ <link href="../../css/rdoc.css" rel="stylesheet">
19
+
20
+
21
+
22
+ <body id="top" role="document" class="class">
23
+ <nav role="navigation">
24
+ <div id="project-navigation">
25
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
26
+ <h2>
27
+ <a href="../../index.html" rel="home">Home</a>
28
+ </h2>
29
+
30
+ <div id="table-of-contents-navigation">
31
+ <a href="../../table_of_contents.html#pages">Pages</a>
32
+ <a href="../../table_of_contents.html#classes">Classes</a>
33
+ <a href="../../table_of_contents.html#methods">Methods</a>
34
+ </div>
35
+ </div>
36
+
37
+ <div id="search-section" role="search" class="project-section initially-hidden">
38
+ <form action="#" method="get" accept-charset="utf-8">
39
+ <div id="search-field-wrapper">
40
+ <input id="search-field" role="combobox" aria-label="Search"
41
+ aria-autocomplete="list" aria-controls="search-results"
42
+ type="text" name="search" placeholder="Search" spellcheck="false"
43
+ title="Type to search, Up and Down to navigate, Enter to load">
44
+ </div>
45
+
46
+ <ul id="search-results" aria-label="Search Results"
47
+ aria-busy="false" aria-expanded="false"
48
+ aria-atomic="false" class="initially-hidden"></ul>
49
+ </form>
50
+ </div>
51
+
52
+ </div>
53
+
54
+
55
+
56
+ <div id="class-metadata">
57
+
58
+ <div id="parent-class-section" class="nav-section">
59
+ <h3>Parent</h3>
60
+
61
+
62
+ <p class="link">Object
63
+
64
+ </div>
65
+
66
+
67
+
68
+ <!-- Method Quickref -->
69
+ <div id="method-list-section" class="nav-section">
70
+ <h3>Methods</h3>
71
+
72
+ <ul class="link-list" role="directory">
73
+
74
+ <li ><a href="#method-c-new">::new</a>
75
+
76
+ <li ><a href="#method-i-max_requests_reached-3F">#max_requests_reached?</a>
77
+
78
+ <li ><a href="#method-i-pause">#pause</a>
79
+
80
+ <li ><a href="#method-i-print-21">#print!</a>
81
+
82
+ <li ><a href="#method-i-resume">#resume</a>
83
+
84
+ </ul>
85
+ </div>
86
+
87
+ </div>
88
+ </nav>
89
+
90
+ <main role="main" aria-labelledby="class-Rack::RubyProf::RackProfiler">
91
+ <h1 id="class-Rack::RubyProf::RackProfiler" class="class">
92
+ class Rack::RubyProf::RackProfiler
93
+ </h1>
94
+
95
+ <section class="description">
96
+
97
+ </section>
98
+
99
+
100
+
101
+
102
+ <section id="5Buntitled-5D" class="documentation-section">
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
113
+ <header>
114
+ <h3>Public Class Methods</h3>
115
+ </header>
116
+
117
+
118
+ <div id="method-c-new" class="method-detail ">
119
+
120
+ <div class="method-heading">
121
+ <span class="method-name">new</span><span
122
+ class="method-args">(options)</span>
123
+
124
+ <span class="method-click-advice">click to toggle source</span>
125
+
126
+ </div>
127
+
128
+
129
+ <div class="method-description">
130
+
131
+
132
+
133
+
134
+
135
+
136
+ <div class="method-source-code" id="new-source">
137
+ <pre><span class="ruby-comment"># File lib/ruby-prof/rack.rb, line 52</span>
138
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>)
139
+ <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
140
+
141
+ <span class="ruby-ivar">@profile</span> = <span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">Profile</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">profiling_options</span>)
142
+ <span class="ruby-ivar">@profile</span>.<span class="ruby-identifier">start</span>
143
+ <span class="ruby-ivar">@profile</span>.<span class="ruby-identifier">pause</span>
144
+
145
+ <span class="ruby-ivar">@printer_klasses</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:printers</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">default_printers</span>
146
+
147
+ <span class="ruby-ivar">@tmpdir</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:path</span>]
148
+
149
+ <span class="ruby-ivar">@max_requests</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:max_requests</span>] <span class="ruby-operator">||</span> <span class="ruby-value">1</span>
150
+ <span class="ruby-ivar">@requests_count</span> = <span class="ruby-value">0</span>
151
+
152
+ <span class="ruby-ivar">@printed</span> = <span class="ruby-keyword">false</span>
153
+ <span class="ruby-comment"># if running across multiple requests, we want to make sure that the</span>
154
+ <span class="ruby-comment"># ongoing profile is not lost if the process shuts down before the</span>
155
+ <span class="ruby-comment"># max request count is reached</span>
156
+ <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">proc</span> { <span class="ruby-identifier">print!</span> })
157
+ <span class="ruby-keyword">end</span></pre>
158
+ </div>
159
+
160
+ </div>
161
+
162
+
163
+
164
+
165
+ </div>
166
+
167
+
168
+ </section>
169
+
170
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
171
+ <header>
172
+ <h3>Public Instance Methods</h3>
173
+ </header>
174
+
175
+
176
+ <div id="method-i-max_requests_reached-3F" class="method-detail ">
177
+
178
+ <div class="method-heading">
179
+ <span class="method-name">max_requests_reached?</span><span
180
+ class="method-args">()</span>
181
+
182
+ <span class="method-click-advice">click to toggle source</span>
183
+
184
+ </div>
185
+
186
+
187
+ <div class="method-description">
188
+
189
+
190
+
191
+
192
+
193
+
194
+ <div class="method-source-code" id="max_requests_reached-3F-source">
195
+ <pre><span class="ruby-comment"># File lib/ruby-prof/rack.rb, line 82</span>
196
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">max_requests_reached?</span>
197
+ <span class="ruby-ivar">@requests_count</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-ivar">@max_requests</span>
198
+ <span class="ruby-keyword">end</span></pre>
199
+ </div>
200
+
201
+ </div>
202
+
203
+
204
+
205
+
206
+ </div>
207
+
208
+
209
+ <div id="method-i-pause" class="method-detail ">
210
+
211
+ <div class="method-heading">
212
+ <span class="method-name">pause</span><span
213
+ class="method-args">()</span>
214
+
215
+ <span class="method-click-advice">click to toggle source</span>
216
+
217
+ </div>
218
+
219
+
220
+ <div class="method-description">
221
+
222
+
223
+
224
+
225
+
226
+
227
+ <div class="method-source-code" id="pause-source">
228
+ <pre><span class="ruby-comment"># File lib/ruby-prof/rack.rb, line 77</span>
229
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">pause</span>
230
+ <span class="ruby-ivar">@profile</span>.<span class="ruby-identifier">pause</span>
231
+ <span class="ruby-ivar">@requests_count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
232
+ <span class="ruby-keyword">end</span></pre>
233
+ </div>
234
+
235
+ </div>
236
+
237
+
238
+
239
+
240
+ </div>
241
+
242
+
243
+ <div id="method-i-print-21" class="method-detail ">
244
+
245
+ <div class="method-heading">
246
+ <span class="method-name">print!</span><span
247
+ class="method-args">(prefix = nil)</span>
248
+
249
+ <span class="method-click-advice">click to toggle source</span>
250
+
251
+ </div>
252
+
253
+
254
+ <div class="method-description">
255
+
256
+
257
+
258
+
259
+
260
+
261
+ <div class="method-source-code" id="print-21-source">
262
+ <pre><span class="ruby-comment"># File lib/ruby-prof/rack.rb, line 86</span>
263
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">print!</span>(<span class="ruby-identifier">prefix</span> = <span class="ruby-keyword">nil</span>)
264
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@printed</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@requests_count</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
265
+
266
+ <span class="ruby-identifier">data</span> = <span class="ruby-ivar">@profile</span>.<span class="ruby-identifier">stop</span>
267
+
268
+ <span class="ruby-identifier">prefix</span> <span class="ruby-operator">||=</span> <span class="ruby-node">&quot;multi-requests-#{@requests_count}&quot;</span>
269
+
270
+ <span class="ruby-ivar">@printer_klasses</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">printer_klass</span>, <span class="ruby-identifier">base_name</span><span class="ruby-operator">|</span>
271
+ <span class="ruby-identifier">printer</span> = <span class="ruby-identifier">printer_klass</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">data</span>)
272
+
273
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">base_name</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:call</span>)
274
+ <span class="ruby-identifier">base_name</span> = <span class="ruby-identifier">base_name</span>.<span class="ruby-identifier">call</span>
275
+ <span class="ruby-keyword">end</span>
276
+
277
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">printer_klass</span> <span class="ruby-operator">==</span> <span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">MultiPrinter</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">printer_klass</span> <span class="ruby-operator">==</span> <span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">CallTreePrinter</span>
278
+ <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-ivar">@options</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value">:profile</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;#{prefix}-#{base_name}&quot;</span>))
279
+ <span class="ruby-keyword">else</span>
280
+ <span class="ruby-identifier">file_name</span> = <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@tmpdir</span>, <span class="ruby-node">&quot;#{prefix}-#{base_name}&quot;</span>)
281
+ <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">file_name</span>, <span class="ruby-string">&#39;wb&#39;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
282
+ <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">file</span>, <span class="ruby-ivar">@options</span>)
283
+ <span class="ruby-keyword">end</span>
284
+ <span class="ruby-keyword">end</span>
285
+ <span class="ruby-keyword">end</span>
286
+
287
+ <span class="ruby-ivar">@printed</span> = <span class="ruby-keyword">true</span>
288
+ <span class="ruby-keyword">end</span></pre>
289
+ </div>
290
+
291
+ </div>
292
+
293
+
294
+
295
+
296
+ </div>
297
+
298
+
299
+ <div id="method-i-resume" class="method-detail ">
300
+
301
+ <div class="method-heading">
302
+ <span class="method-name">resume</span><span
303
+ class="method-args">()</span>
304
+
305
+ <span class="method-click-advice">click to toggle source</span>
306
+
307
+ </div>
308
+
309
+
310
+ <div class="method-description">
311
+
312
+
313
+
314
+
315
+
316
+
317
+ <div class="method-source-code" id="resume-source">
318
+ <pre><span class="ruby-comment"># File lib/ruby-prof/rack.rb, line 73</span>
319
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">resume</span>
320
+ <span class="ruby-ivar">@profile</span>.<span class="ruby-identifier">resume</span>
321
+ <span class="ruby-keyword">end</span></pre>
322
+ </div>
323
+
324
+ </div>
325
+
326
+
327
+
328
+
329
+ </div>
330
+
331
+
332
+ </section>
333
+
334
+ </section>
335
+ </main>
336
+
337
+
338
+ <footer id="validator-badges" role="contentinfo">
339
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
340
+ <p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
341
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
342
+ </footer>
343
+