ruby-prof 0.15.3 → 0.15.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +9 -0
  3. data/README.rdoc +24 -39
  4. data/bin/ruby-prof +1 -2
  5. data/doc/created.rid +8 -8
  6. data/doc/js/search_index.js +1 -1
  7. data/doc/js/search_index.js.gz +0 -0
  8. data/ext/ruby_prof/rp_measure.c +20 -28
  9. data/ext/ruby_prof/rp_measure.h +6 -6
  10. data/ext/ruby_prof/rp_measure_allocations.c +9 -2
  11. data/ext/ruby_prof/rp_measure_memory.c +4 -0
  12. data/lib/ruby-prof.rb +9 -20
  13. data/lib/ruby-prof/compatibility.rb +12 -4
  14. data/lib/ruby-prof/printers/flat_printer.rb +1 -0
  15. data/lib/ruby-prof/version.rb +1 -1
  16. data/test/thread_test.rb +7 -4
  17. metadata +2 -54
  18. data/doc/LICENSE.html +0 -114
  19. data/doc/README_rdoc.html +0 -607
  20. data/doc/Rack.html +0 -95
  21. data/doc/Rack/RubyProf.html +0 -264
  22. data/doc/RubyProf.html +0 -965
  23. data/doc/RubyProf/AbstractPrinter.html +0 -546
  24. data/doc/RubyProf/AggregateCallInfo.html +0 -537
  25. data/doc/RubyProf/CallInfo.html +0 -468
  26. data/doc/RubyProf/CallInfoPrinter.html +0 -120
  27. data/doc/RubyProf/CallInfoVisitor.html +0 -200
  28. data/doc/RubyProf/CallStackPrinter.html +0 -1604
  29. data/doc/RubyProf/CallTreePrinter.html +0 -359
  30. data/doc/RubyProf/Cmd.html +0 -624
  31. data/doc/RubyProf/DotPrinter.html +0 -257
  32. data/doc/RubyProf/FlatPrinter.html +0 -163
  33. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +0 -201
  34. data/doc/RubyProf/GraphHtmlPrinter.html +0 -575
  35. data/doc/RubyProf/GraphPrinter.html +0 -139
  36. data/doc/RubyProf/MethodInfo.html +0 -685
  37. data/doc/RubyProf/MultiPrinter.html +0 -358
  38. data/doc/RubyProf/Profile.html +0 -764
  39. data/doc/RubyProf/ProfileTask.html +0 -490
  40. data/doc/RubyProf/Thread.html +0 -199
  41. data/doc/examples/flat_txt.html +0 -149
  42. data/doc/examples/graph_html.html +0 -850
  43. data/doc/examples/graph_txt.html +0 -274
  44. data/doc/images/add.png +0 -0
  45. data/doc/images/arrow_up.png +0 -0
  46. data/doc/images/brick.png +0 -0
  47. data/doc/images/brick_link.png +0 -0
  48. data/doc/images/bug.png +0 -0
  49. data/doc/images/bullet_black.png +0 -0
  50. data/doc/images/bullet_toggle_minus.png +0 -0
  51. data/doc/images/bullet_toggle_plus.png +0 -0
  52. data/doc/images/date.png +0 -0
  53. data/doc/images/delete.png +0 -0
  54. data/doc/images/find.png +0 -0
  55. data/doc/images/macFFBgHack.png +0 -0
  56. data/doc/images/package.png +0 -0
  57. data/doc/images/page_green.png +0 -0
  58. data/doc/images/page_white_text.png +0 -0
  59. data/doc/images/page_white_width.png +0 -0
  60. data/doc/images/plugin.png +0 -0
  61. data/doc/images/ruby.png +0 -0
  62. data/doc/images/tag_blue.png +0 -0
  63. data/doc/images/tag_green.png +0 -0
  64. data/doc/images/transparent.png +0 -0
  65. data/doc/images/wrench.png +0 -0
  66. data/doc/images/wrench_orange.png +0 -0
  67. data/doc/images/zoom.png +0 -0
  68. data/doc/index.html +0 -633
  69. data/doc/table_of_contents.html +0 -859
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.3
4
+ version: 0.15.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda, Charlie Savage, Roger Pack, Stefan Kaes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2015-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -73,67 +73,16 @@ files:
73
73
  - Rakefile
74
74
  - bin/ruby-prof
75
75
  - bin/ruby-prof-check-trace
76
- - doc/LICENSE.html
77
- - doc/README_rdoc.html
78
- - doc/Rack.html
79
- - doc/Rack/RubyProf.html
80
- - doc/RubyProf.html
81
- - doc/RubyProf/AbstractPrinter.html
82
- - doc/RubyProf/AggregateCallInfo.html
83
- - doc/RubyProf/CallInfo.html
84
- - doc/RubyProf/CallInfoPrinter.html
85
- - doc/RubyProf/CallInfoVisitor.html
86
- - doc/RubyProf/CallStackPrinter.html
87
- - doc/RubyProf/CallTreePrinter.html
88
- - doc/RubyProf/Cmd.html
89
- - doc/RubyProf/DotPrinter.html
90
- - doc/RubyProf/FlatPrinter.html
91
- - doc/RubyProf/FlatPrinterWithLineNumbers.html
92
- - doc/RubyProf/GraphHtmlPrinter.html
93
- - doc/RubyProf/GraphPrinter.html
94
- - doc/RubyProf/MethodInfo.html
95
- - doc/RubyProf/MultiPrinter.html
96
- - doc/RubyProf/Profile.html
97
- - doc/RubyProf/ProfileTask.html
98
- - doc/RubyProf/Thread.html
99
76
  - doc/created.rid
100
77
  - doc/css/fonts.css
101
78
  - doc/css/rdoc.css
102
- - doc/examples/flat_txt.html
103
- - doc/examples/graph_html.html
104
- - doc/examples/graph_txt.html
105
79
  - doc/fonts/Lato-Light.ttf
106
80
  - doc/fonts/Lato-LightItalic.ttf
107
81
  - doc/fonts/Lato-Regular.ttf
108
82
  - doc/fonts/Lato-RegularItalic.ttf
109
83
  - doc/fonts/SourceCodePro-Bold.ttf
110
84
  - doc/fonts/SourceCodePro-Regular.ttf
111
- - doc/images/add.png
112
- - doc/images/arrow_up.png
113
- - doc/images/brick.png
114
- - doc/images/brick_link.png
115
- - doc/images/bug.png
116
- - doc/images/bullet_black.png
117
- - doc/images/bullet_toggle_minus.png
118
- - doc/images/bullet_toggle_plus.png
119
- - doc/images/date.png
120
- - doc/images/delete.png
121
- - doc/images/find.png
122
85
  - doc/images/loadingAnimation.gif
123
- - doc/images/macFFBgHack.png
124
- - doc/images/package.png
125
- - doc/images/page_green.png
126
- - doc/images/page_white_text.png
127
- - doc/images/page_white_width.png
128
- - doc/images/plugin.png
129
- - doc/images/ruby.png
130
- - doc/images/tag_blue.png
131
- - doc/images/tag_green.png
132
- - doc/images/transparent.png
133
- - doc/images/wrench.png
134
- - doc/images/wrench_orange.png
135
- - doc/images/zoom.png
136
- - doc/index.html
137
86
  - doc/js/darkfish.js
138
87
  - doc/js/jquery.js
139
88
  - doc/js/navigation.js
@@ -143,7 +92,6 @@ files:
143
92
  - doc/js/search_index.js.gz
144
93
  - doc/js/searcher.js
145
94
  - doc/js/searcher.js.gz
146
- - doc/table_of_contents.html
147
95
  - examples/empty.png
148
96
  - examples/flat.txt
149
97
  - examples/graph.dot
data/doc/LICENSE.html DELETED
@@ -1,114 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>LICENSE - ruby-prof</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "./";
11
- </script>
12
-
13
- <script src="./js/jquery.js"></script>
14
- <script src="./js/darkfish.js"></script>
15
-
16
- <link href="./css/fonts.css" rel="stylesheet">
17
- <link href="./css/rdoc.css" rel="stylesheet">
18
-
19
-
20
-
21
- <body id="top" role="document" class="file">
22
- <nav role="navigation">
23
- <div id="project-navigation">
24
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
25
- <h2>
26
- <a href="./index.html" rel="home">Home</a>
27
- </h2>
28
-
29
- <div id="table-of-contents-navigation">
30
- <a href="./table_of_contents.html#pages">Pages</a>
31
- <a href="./table_of_contents.html#classes">Classes</a>
32
- <a href="./table_of_contents.html#methods">Methods</a>
33
- </div>
34
- </div>
35
-
36
- <div id="search-section" role="search" class="project-section initially-hidden">
37
- <form action="#" method="get" accept-charset="utf-8">
38
- <div id="search-field-wrapper">
39
- <input id="search-field" role="combobox" aria-label="Search"
40
- aria-autocomplete="list" aria-controls="search-results"
41
- type="text" name="search" placeholder="Search" spellcheck="false"
42
- title="Type to search, Up and Down to navigate, Enter to load">
43
- </div>
44
-
45
- <ul id="search-results" aria-label="Search Results"
46
- aria-busy="false" aria-expanded="false"
47
- aria-atomic="false" class="initially-hidden"></ul>
48
- </form>
49
- </div>
50
-
51
- </div>
52
-
53
-
54
-
55
- <div id="project-metadata">
56
- <div id="fileindex-section" class="nav-section">
57
- <h3>Pages</h3>
58
-
59
- <ul class="link-list">
60
-
61
- <li><a href="./LICENSE.html">LICENSE</a>
62
-
63
- <li><a href="./README_rdoc.html">README</a>
64
-
65
- <li><a href="./examples/flat_txt.html">flat</a>
66
-
67
- <li><a href="./examples/graph_html.html">graph.html</a>
68
-
69
- <li><a href="./examples/graph_txt.html">graph</a>
70
-
71
- </ul>
72
- </div>
73
-
74
- </div>
75
- </nav>
76
-
77
- <main role="main" aria-label="Page LICENSE">
78
-
79
- <p>Copyright (C) 2005 - 2014 Shugo Maeda &lt;shugo@ruby-lang.org&gt; and
80
- Charlie Savage &lt;cfis@savagexi.com&gt; Copyright (C) 2010 - 2014 Stefan
81
- Kaes &lt;skaes@railsepxress.de&gt; All rights reserved.</p>
82
-
83
- <p>Redistribution and use in source and binary forms, with or without
84
- modification, are permitted provided that the following conditions are met:</p>
85
- <ol><li>
86
- <p>Redistributions of source code must retain the above copyright notice, this
87
- list of conditions and the following disclaimer.</p>
88
- </li><li>
89
- <p>Redistributions in binary form must reproduce the above copyright notice,
90
- this list of conditions and the following disclaimer in the documentation
91
- and/or other materials provided with the distribution.</p>
92
- </li></ol>
93
-
94
- <p>THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS “AS IS&#39;&#39;
95
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
97
- ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
98
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
99
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
100
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
101
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
102
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
103
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
104
- DAMAGE.</p>
105
- </main>
106
-
107
-
108
-
109
- <footer id="validator-badges" role="contentinfo">
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.
112
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
113
- </footer>
114
-
data/doc/README_rdoc.html DELETED
@@ -1,607 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>README - ruby-prof</title>
8
-
9
- <script type="text/javascript">
10
- var rdoc_rel_prefix = "./";
11
- </script>
12
-
13
- <script src="./js/jquery.js"></script>
14
- <script src="./js/darkfish.js"></script>
15
-
16
- <link href="./css/fonts.css" rel="stylesheet">
17
- <link href="./css/rdoc.css" rel="stylesheet">
18
-
19
-
20
-
21
- <body id="top" role="document" class="file">
22
- <nav role="navigation">
23
- <div id="project-navigation">
24
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
25
- <h2>
26
- <a href="./index.html" rel="home">Home</a>
27
- </h2>
28
-
29
- <div id="table-of-contents-navigation">
30
- <a href="./table_of_contents.html#pages">Pages</a>
31
- <a href="./table_of_contents.html#classes">Classes</a>
32
- <a href="./table_of_contents.html#methods">Methods</a>
33
- </div>
34
- </div>
35
-
36
- <div id="search-section" role="search" class="project-section initially-hidden">
37
- <form action="#" method="get" accept-charset="utf-8">
38
- <div id="search-field-wrapper">
39
- <input id="search-field" role="combobox" aria-label="Search"
40
- aria-autocomplete="list" aria-controls="search-results"
41
- type="text" name="search" placeholder="Search" spellcheck="false"
42
- title="Type to search, Up and Down to navigate, Enter to load">
43
- </div>
44
-
45
- <ul id="search-results" aria-label="Search Results"
46
- aria-busy="false" aria-expanded="false"
47
- aria-atomic="false" class="initially-hidden"></ul>
48
- </form>
49
- </div>
50
-
51
- </div>
52
-
53
-
54
- <div class="nav-section">
55
- <h3>Table of Contents</h3>
56
-
57
- <ul class="link-list" role="directory">
58
- <li><a href="#label-ruby-prof">ruby-prof</a>
59
- <li><a href="#label-Overview">Overview</a>
60
- <li><a href="#label-Requirements">Requirements</a>
61
- <li><a href="#label-Install">Install</a>
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>
66
- <li><a href="#label-Benchmarking+full+load+time+including+rubygems+startup+cost">Benchmarking full load time including rubygems startup cost</a>
67
- <li><a href="#label-Profiling+Rails">Profiling Rails</a>
68
- <li><a href="#label-Reports">Reports</a>
69
- <li><a href="#label-Printers">Printers</a>
70
- <li><a href="#label-Measurements">Measurements</a>
71
- <li><a href="#label-Multi-threaded+Applications">Multi-threaded Applications</a>
72
- <li><a href="#label-Performance">Performance</a>
73
- <li><a href="#label-License">License</a>
74
- <li><a href="#label-Development">Development</a>
75
- </ul>
76
- </div>
77
-
78
-
79
- <div id="project-metadata">
80
- <div id="fileindex-section" class="nav-section">
81
- <h3>Pages</h3>
82
-
83
- <ul class="link-list">
84
-
85
- <li><a href="./LICENSE.html">LICENSE</a>
86
-
87
- <li><a href="./README_rdoc.html">README</a>
88
-
89
- <li><a href="./examples/flat_txt.html">flat</a>
90
-
91
- <li><a href="./examples/graph_html.html">graph.html</a>
92
-
93
- <li><a href="./examples/graph_txt.html">graph</a>
94
-
95
- </ul>
96
- </div>
97
-
98
- </div>
99
- </nav>
100
-
101
- <main role="main" aria-label="Page README.rdoc">
102
-
103
- <h1 id="label-ruby-prof">ruby-prof<span><a href="#label-ruby-prof">&para;</a> <a href="#top">&uarr;</a></span></h1>
104
-
105
- <p><a href="https://travis-ci.org/ruby-prof/ruby-prof"><img
106
- src="https://travis-ci.org/ruby-prof/ruby-prof.png?branch=master"
107
- alt="Build Status" /></a></p>
108
-
109
- <h2 id="label-Overview">Overview<span><a href="#label-Overview">&para;</a> <a href="#top">&uarr;</a></span></h2>
110
-
111
- <p>ruby-prof is a fast code profiler for Ruby. Its features include:</p>
112
- <ul><li>
113
- <p>Speed - it is a C extension and therefore many times faster than the
114
- standard Ruby profiler.</p>
115
- </li><li>
116
- <p>Modes - Ruby prof can measure a number of different parameters, including
117
- call times, memory usage and object allocations.</p>
118
- </li><li>
119
- <p>Reports - can generate text and cross-referenced html reports</p>
120
- <ul><li>
121
- <p>Flat Profiles - similar to the reports generated by the standard Ruby
122
- profiler</p>
123
- </li><li>
124
- <p>Graph profiles - similar to GProf, these show how long a method runs, which
125
- methods call it and which methods it calls.</p>
126
- </li><li>
127
- <p>Call tree profiles - outputs results in the calltree format suitable for
128
- the KCacheGrind profiling tool.</p>
129
- </li><li>
130
- <p>Many more – see reports section of this <a
131
- href="README_rdoc.html">README</a>.</p>
132
- </li></ul>
133
- </li><li>
134
- <p>Threads - supports profiling multiple threads simultaneously</p>
135
- </li></ul>
136
-
137
- <h2 id="label-Requirements">Requirements<span><a href="#label-Requirements">&para;</a> <a href="#top">&uarr;</a></span></h2>
138
-
139
- <p>ruby-prof requires Ruby 1.9.3 or higher.</p>
140
-
141
- <p>If you are running Linux or Unix you&#39;ll need a C compiler so the
142
- extension can be compiled when it is installed.</p>
143
-
144
- <p>If you are running Windows, then you may need to install the Windows
145
- specific RubyGem which includes an already built extension (see Install
146
- section).</p>
147
-
148
- <h2 id="label-Install">Install<span><a href="#label-Install">&para;</a> <a href="#top">&uarr;</a></span></h2>
149
-
150
- <p>The easiest way to install ruby-prof is by using Ruby Gems. To install:</p>
151
-
152
- <pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-identifier">install</span> <span class="ruby-identifier">ruby</span><span class="ruby-operator">-</span><span class="ruby-identifier">prof</span>
153
- </pre>
154
-
155
- <p>If you&#39;re on windows then please install the devkit first so that it
156
- can compile.</p>
157
-
158
- <h2 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>
159
-
160
- <p>There are two ways of running ruby-prof, via the command line or via its
161
- API.</p>
162
-
163
- <h3 id="label-ruby-prof+executable">ruby-prof executable<span><a href="#label-ruby-prof+executable">&para;</a> <a href="#top">&uarr;</a></span></h3>
164
-
165
- <p>The first is to use ruby-prof to run the Ruby program you want to profile.
166
- For more information refer to the documentation of the ruby-prof command.</p>
167
-
168
- <h3 id="label-ruby-prof+API">ruby-prof API<span><a href="#label-ruby-prof+API">&para;</a> <a href="#top">&uarr;</a></span></h3>
169
-
170
- <p>The second way is to use the ruby-prof API to profile particular segments
171
- of code.</p>
172
-
173
- <pre>require &#39;ruby-prof&#39;
174
-
175
- # Profile the code
176
- RubyProf.start
177
- ...
178
- [code to profile]
179
- ...
180
- result = RubyProf.stop
181
-
182
- # Print a flat profile to text
183
- printer = RubyProf::FlatPrinter.new(result)
184
- printer.print(STDOUT)</pre>
185
-
186
- <p>Alternatively, you can use a block to tell ruby-prof what to profile:</p>
187
-
188
- <pre>require &#39;ruby-prof&#39;
189
-
190
- # Profile the code
191
- result = RubyProf.profile do
192
- ...
193
- [code to profile]
194
- ...
195
- end
196
-
197
- # Print a graph profile to text
198
- printer = RubyProf::GraphPrinter.new(result)
199
- printer.print(STDOUT, {})</pre>
200
-
201
- <p>ruby-prof also supports pausing and resuming profiling runs.</p>
202
-
203
- <pre>require &#39;ruby-prof&#39;
204
-
205
- # Profile the code
206
- RubyProf.start
207
- [code to profile]
208
- RubyProf.pause
209
- [other code]
210
- RubyProf.resume
211
- [code to profile]
212
- result = RubyProf.stop</pre>
213
-
214
- <p>Note that resume will automatically call start if a profiling run has not
215
- yet started. In addition, resume can also take a block:</p>
216
-
217
- <pre>require &#39;ruby-prof&#39;
218
-
219
- # Profile the code
220
- RubyProf.resume do
221
- [code to profile]
222
- end
223
-
224
- data = RubyProf.stop</pre>
225
-
226
- <p>With this usage, resume will automatically call pause at the end of the
227
- block.</p>
228
-
229
- <h2 id="label-Method+and+Thread+Elimination">Method and Thread Elimination<span><a href="#label-Method+and+Thread+Elimination">&para;</a> <a href="#top">&uarr;</a></span></h2>
230
-
231
- <p>ruby-prof supports eliminating specific methods and threads from profiling
232
- results. This is useful for reducing connectivity in the call graph, making
233
- it easier to identify the source of performance problems when using a graph
234
- printer.</p>
235
-
236
- <p>For example, consider Integer#times: it&#39;s hardly ever useful to know
237
- how much time is spent in the method itself. We&#39;re much more interested
238
- in how much the passed in block contributes to the time spent in the method
239
- which contains the Integer#times call.</p>
240
-
241
- <p>Methods are eliminated from the collected data by calling
242
- `eliminate_methods!` on the profiling result, before submitting it to a
243
- printer.</p>
244
-
245
- <pre class="ruby"><span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
246
- <span class="ruby-identifier">result</span>.<span class="ruby-identifier">eliminate_methods!</span>([<span class="ruby-node">/Integer#times/</span>])
247
- </pre>
248
-
249
- <p>The argument given to `eliminate_methods!` is either an array of regular
250
- expressions, or the name of a file containing a list of regular expressions
251
- (line separated text).</p>
252
-
253
- <p>After eliminating methods the resulting profile will appear exactly as if
254
- those methods had been inlined at their call sites.</p>
255
-
256
- <p>In a similar manner, threads can be excluded so they are not profiled at
257
- all. To do this, pass an array of threads to exclude to ruby-prof:</p>
258
-
259
- <pre class="ruby"><span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-identifier">exclude_threads</span> = [ <span class="ruby-identifier">thread2</span> ]
260
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
261
- </pre>
262
-
263
- <p>Note that the excluded threads must be specified <strong>before</strong>
264
- profiling.</p>
265
-
266
- <h2 id="label-Benchmarking+full+load+time+including+rubygems+startup+cost">Benchmarking full load time including rubygems startup cost<span><a href="#label-Benchmarking+full+load+time+including+rubygems+startup+cost">&para;</a> <a href="#top">&uarr;</a></span></h2>
267
-
268
- <p>If you want to get a more accurate measurement of what takes all of a
269
- gem&#39;s bin/xxx command to load, you may want to also measure
270
- rubygems&#39; startup penalty. You can do this by calling into
271
- bin/ruby-prof directly, ex:</p>
272
-
273
- <p>$ gem which ruby-prof</p>
274
-
275
- <pre>g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/lib/ruby-prof.rb</pre>
276
-
277
- <p>now run it thus (substitute lib/ruby-prof.rb with bin/ruby-prof):</p>
278
-
279
- <p>$ ruby g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/bin/ruby-prof
280
- g:192binsome_installed_gem_command</p>
281
-
282
- <p>or</p>
283
-
284
- <p>$ ruby g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/bin/ruby-prof
285
- ./some_file_that_does_a_require_rubygems_at_the_beginning.rb</p>
286
-
287
- <h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">&para;</a> <a href="#top">&uarr;</a></span></h2>
288
-
289
- <p>To profile a Rails application it is vital to run it using production like
290
- settings (cache classes, cache view lookups, etc.). Otherwise, Rail&#39;s
291
- dependency loading code will overwhelm any time spent in the application
292
- itself (our tests show that Rails dependency loading causes a roughly 6x
293
- slowdown). The best way to do this is create a new Rails environment,
294
- profile.rb.</p>
295
-
296
- <p>So to profile Rails:</p>
297
- <ol><li>
298
- <p>Create a new profile.rb environment. Make sure to turn on cache_classes
299
- and cache_template_loading. Otherwise your profiling results will be
300
- overwhelemed by the time Rails spends loading required files. You should
301
- likely turn off caching.</p>
302
- </li><li>
303
- <p>Add the ruby-prof to your gemfile:</p>
304
-
305
- <pre class="ruby"><span class="ruby-identifier">group</span> :<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
306
- <span class="ruby-identifier">gem</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
307
- <span class="ruby-keyword">end</span>
308
- </pre>
309
- </li><li>
310
- <p>Add the ruby prof rack adapter to your middleware stack. One way to do
311
- this is by adding the following code to config.ru:</p>
312
-
313
- <pre class="ruby"><span class="ruby-keyword">if</span> <span class="ruby-constant">Rails</span>.<span class="ruby-identifier">env</span>.<span class="ruby-identifier">profile?</span>
314
- <span class="ruby-identifier">use</span> <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">RubyProf</span>, :<span class="ruby-identifier">path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;/temp/profile&#39;</span>
315
- <span class="ruby-keyword">end</span>
316
- </pre>
317
-
318
- <p>The path is where you want profiling results to be stored. By default the
319
- rack adapter will generate a html call graph report and flat text report.</p>
320
- </li><li>
321
- <p>Now make a request to your running server. New profiling information will
322
- be generated for each request. Note that each request will overwrite the
323
- profiling reports created by the previous request!</p>
324
- </li></ol>
325
-
326
- <h2 id="label-Reports">Reports<span><a href="#label-Reports">&para;</a> <a href="#top">&uarr;</a></span></h2>
327
-
328
- <p>ruby-prof can generate a number of different reports:</p>
329
- <ul><li>
330
- <p>Flat Reports</p>
331
- </li><li>
332
- <p>Graph Reports</p>
333
- </li><li>
334
- <p>HTML Graph Reports</p>
335
- </li><li>
336
- <p>Call graphs</p>
337
- </li><li>
338
- <p>Call stack reports</p>
339
- </li><li>
340
- <p>More!</p>
341
- </li></ul>
342
-
343
- <p>Flat profiles show the overall time spent in each method. They are a good
344
- of quickly identifying which methods take the most time. An example of a
345
- flat profile and an explanation can be found in <a
346
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/flat.txt">examples/flat.txt</a>.</p>
347
-
348
- <p>There are several varieties of these – run $ ruby-prof –help</p>
349
-
350
- <p>Graph profiles also show the overall time spent in each method. In
351
- addition, they also show which methods call the current method and which
352
- methods its calls. Thus they are good for understanding how methods gets
353
- called and provide insight into the flow of your program. An example text
354
- graph profile is located at <a
355
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.txt">examples/graph.txt</a>.</p>
356
-
357
- <p>HTML Graph profiles are the same as graph profiles, except output is
358
- generated in hyper-linked HTML. Since graph profiles can be quite large,
359
- the embedded links make it much easier to navigate the results. An example
360
- html graph profile is located at <a
361
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.html">examples/graph.html</a>.</p>
362
-
363
- <p>Call graphs output results in the calltree profile format which is used by
364
- KCachegrind. Call graph support was generously donated by Carl Shimer. More
365
- information about the format can be found at the <a
366
- href="http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindCalltreeFormat">KCachegrind</a>
367
- site.</p>
368
-
369
- <p>Call stack reports produce a HTML visualization of the time spent in each
370
- execution path of the profiled code. An example can be found at <a
371
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/call_stack.html">examples/stack.html</a>.</p>
372
-
373
- <p>Another good example: [<a
374
- href="http://twitpic.com/28z94a">twitpic.com/28z94a</a>]</p>
375
-
376
- <p>Finally, there&#39;s a so called MultiPrinter which can generate several
377
- reports in one profiling run. See <a
378
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/multi.stack.html">examples/multi.stack.html</a>.</p>
379
-
380
- <p>There is also a graphviz .dot visualiser.</p>
381
-
382
- <h2 id="label-Printers">Printers<span><a href="#label-Printers">&para;</a> <a href="#top">&uarr;</a></span></h2>
383
-
384
- <p>Reports are created by printers. Supported printers include:</p>
385
- <ul><li>
386
- <p><a href="RubyProf/FlatPrinter.html">RubyProf::FlatPrinter</a> - Creates a
387
- flat report in text format</p>
388
- </li><li>
389
- <p><a
390
- href="RubyProf/FlatPrinterWithLineNumbers.html">RubyProf::FlatPrinterWithLineNumbers</a>
391
- - same as above but more verbose</p>
392
- </li><li>
393
- <p><a href="RubyProf/GraphPrinter.html">RubyProf::GraphPrinter</a> - Creates a
394
- call graph report in text format</p>
395
- </li><li>
396
- <p><a href="RubyProf/GraphHtmlPrinter.html">RubyProf::GraphHtmlPrinter</a> -
397
- Creates a call graph report in HTML (separate files per thread)</p>
398
- </li><li>
399
- <p><a href="RubyProf/DotPrinter.html">RubyProf::DotPrinter</a> - Creates a
400
- call graph report in GraphViz&#39;s DOT format which can be converted to an
401
- image</p>
402
- </li><li>
403
- <p><a href="RubyProf/CallTreePrinter.html">RubyProf::CallTreePrinter</a> -
404
- Creates a call tree report compatible with KCachegrind.</p>
405
- </li><li>
406
- <p><a href="RubyProf/CallStackPrinter.html">RubyProf::CallStackPrinter</a> -
407
- Creates a HTML visualization of the Ruby stack</p>
408
- </li><li>
409
- <p><a href="RubyProf/MultiPrinter.html">RubyProf::MultiPrinter</a> - Uses the
410
- other printers to create several reports in one profiling run</p>
411
- </li><li>
412
- <p>More!</p>
413
- </li></ul>
414
-
415
- <p>To use a printer:</p>
416
-
417
- <pre>...
418
- result = RubyProf.stop
419
- printer = RubyProf::GraphPrinter.new(result)
420
- printer.print(STDOUT, :min_percent =&gt; 2)</pre>
421
-
422
- <p>The first parameter is any writable IO object such as STDOUT or a file. The
423
- second parameter, specifies the minimum percentage a method must take to be
424
- printed. Percentages should be specified as integers in the range 0 to
425
- 100. For more information please see the documentation for the different
426
- printers.</p>
427
-
428
- <p>The other option is :print_file =&gt; true (default false), which adds the
429
- filename to the output (GraphPrinter only).</p>
430
-
431
- <p>The MultiPrinter differs from the other printers in that it requires a
432
- directory path and a basename for the files it produces.</p>
433
-
434
- <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>)
435
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(:<span class="ruby-identifier">path</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;.&quot;</span>, :<span class="ruby-identifier">profile</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;profile&quot;</span>)
436
- </pre>
437
-
438
- <h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">&para;</a> <a href="#top">&uarr;</a></span></h2>
439
-
440
- <p>Depending on the mode and platform, ruby-prof can measure various aspects
441
- of a Ruby program. Supported measurements include:</p>
442
- <ul><li>
443
- <p>process time (RubyProf::PROCESS_TIME)</p>
444
- </li><li>
445
- <p>wall time (RubyProf::WALL_TIME)</p>
446
- </li><li>
447
- <p>cpu time (RubyProf::CPU_TIME)</p>
448
- </li><li>
449
- <p>object allocations (RubyProf::ALLOCATIONS)</p>
450
- </li><li>
451
- <p>memory usage (RubyProf::MEMORY)</p>
452
- </li><li>
453
- <p>garbage collections runs (RubyProf::GC_RUNS)</p>
454
- </li><li>
455
- <p>garbage collection time (RubyProf::GC_TIME)</p>
456
- </li></ul>
457
-
458
- <p>Process time measures the time used by a process between any two moments.
459
- It is unaffected by other processes concurrently running on the system.
460
- Note that Windows does not support measuring process times - therefore,
461
- measurements on Windows defaults to wall time.</p>
462
-
463
- <p>Wall time measures the real-world time elapsed between any two moments. If
464
- there are other processes concurrently running on the system that use
465
- significant CPU or disk time during a profiling run then the reported
466
- results will be too large.</p>
467
-
468
- <p>CPU time uses the CPU clock counter to measure time. The returned values
469
- are dependent on the correctly setting the CPU&#39;s frequency. This mode
470
- is only supported on Pentium or PowerPC platforms (linux only).</p>
471
-
472
- <p>Object allocation reports show how many objects each method in a program
473
- allocates. This support was added by Sylvain Joyeux and requires a patched
474
- Ruby interpreter. See below.</p>
475
-
476
- <p>Memory usage reports show how much memory each method in a program uses.
477
- This support was added by Alexander Dymo and requires a patched Ruby
478
- interpreter. See below.</p>
479
-
480
- <p>Garbage collection runs report how many times Ruby&#39;s garbage collector
481
- is invoked during a profiling session. This support was added by Jeremy
482
- Kemper and requires a patched Ruby interpreter. See below.</p>
483
-
484
- <p>Garbage collection time reports how much time is spent in Ruby&#39;s
485
- garbage collector during a profiling session. This support was added by
486
- Jeremy Kemper and requires a patched Ruby interpreter. See below.</p>
487
-
488
- <p>Ruby patches: all of the patches to Ruby are included in the railsexpress
489
- patchsets for rvm, see <a
490
- href="https://github.com/skaes/rvm-patchsets">github.com/skaes/rvm-patchsets</a></p>
491
-
492
- <p>To set the measurement:</p>
493
- <ul><li>
494
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
495
- RubyProf::PROCESS_TIME</p>
496
- </li><li>
497
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
498
- RubyProf::WALL_TIME</p>
499
- </li><li>
500
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
501
- RubyProf::CPU_TIME</p>
502
- </li><li>
503
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
504
- RubyProf::ALLOCATIONS</p>
505
- </li><li>
506
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
507
- RubyProf::MEMORY</p>
508
- </li><li>
509
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
510
- RubyProf::GC_RUNS</p>
511
- </li><li>
512
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
513
- RubyProf::GC_TIME</p>
514
- </li></ul>
515
-
516
- <p>The default value is RubyProf::PROCESS_TIME.</p>
517
-
518
- <p>You may also specify the measure_mode by using the RUBY_PROF_MEASURE_MODE
519
- environment variable:</p>
520
- <ul><li>
521
- <p>export RUBY_PROF_MEASURE_MODE=process</p>
522
- </li><li>
523
- <p>export RUBY_PROF_MEASURE_MODE=wall</p>
524
- </li><li>
525
- <p>export RUBY_PROF_MEASURE_MODE=cpu</p>
526
- </li><li>
527
- <p>export RUBY_PROF_MEASURE_MODE=allocations</p>
528
- </li><li>
529
- <p>export RUBY_PROF_MEASURE_MODE=memory</p>
530
- </li><li>
531
- <p>export RUBY_PROF_MEASURE_MODE=gc_runs</p>
532
- </li><li>
533
- <p>export RUBY_PROF_MEASURE_MODE=gc_time</p>
534
- </li></ul>
535
-
536
- <p>On Linux, process time is measured using the clock method provided by the C
537
- runtime library. Note that the clock method does not report time spent in
538
- the kernel or child processes and therefore does not measure time spent in
539
- methods such as Kernel.sleep method. If you need to measure these values,
540
- then use wall time. Wall time is measured using the gettimeofday kernel
541
- method.</p>
542
-
543
- <p>On Windows, timings default to wall times. If you set the clock mode to
544
- PROCESS_TIME, then timing are read using the clock method provided by the C
545
- runtime library. Note though, these values are wall times on Windows and
546
- not process times like on Linux. Wall time is measured using the
547
- GetLocalTime API.</p>
548
-
549
- <p>If you use wall time, the results will be affected by other processes
550
- running on your computer, network delays, disk access, etc. As result, for
551
- the best results, try to make sure your computer is only performing your
552
- profiling run and is otherwise quiescent.</p>
553
-
554
- <p>On both platforms, cpu time is measured using the RDTSC assembly function
555
- provided by the Pentium and PowerPC platforms. CPU time is dependent on the
556
- cpu&#39;s frequency. On Linux, ruby-prof attempts to read this value from
557
- “/proc/cpuinfo.” On Windows, you must manually specify the clock
558
- frequency. This can be done using the RUBY_PROF_CPU_FREQUENCY environment
559
- variable:</p>
560
-
561
- <pre>export RUBY_PROF_CPU_FREQUENCY=&lt;value&gt;</pre>
562
-
563
- <p>You can also directly set the cpu frequency by calling:</p>
564
-
565
- <pre>RubyProf.cpu_frequency = &lt;value&gt;</pre>
566
-
567
- <h2 id="label-Multi-threaded+Applications">Multi-threaded Applications<span><a href="#label-Multi-threaded+Applications">&para;</a> <a href="#top">&uarr;</a></span></h2>
568
-
569
- <p>Unfortunately, Ruby does not provide an internal api for detecting thread
570
- context switches in 1.8. As a result, the timings ruby-prof reports for
571
- each thread may be slightly inaccurate. In particular, this will happen
572
- for newly spawned threads that go to sleep immediately (their first call).
573
- For instance, if you use Ruby&#39;s timeout library to wait for 2 seconds,
574
- the 2 seconds will be assigned to the foreground thread and not the newly
575
- created background thread. These errors can largely be avoided if the
576
- background thread performs any operation before going to sleep.</p>
577
-
578
- <h2 id="label-Performance">Performance<span><a href="#label-Performance">&para;</a> <a href="#top">&uarr;</a></span></h2>
579
-
580
- <p>Significant effort has been put into reducing ruby-prof&#39;s overhead as
581
- much as possible. Our tests show that the overhead associated with
582
- profiling code varies considerably with the code being profiled. Most
583
- programs will run approximately twice as slow while highly recursive
584
- programs (like the fibonacci series test) will run three times slower.</p>
585
-
586
- <h2 id="label-License">License<span><a href="#label-License">&para;</a> <a href="#top">&uarr;</a></span></h2>
587
-
588
- <p>See <a href="LICENSE.html">LICENSE</a> for license information.</p>
589
-
590
- <h2 id="label-Development">Development<span><a href="#label-Development">&para;</a> <a href="#top">&uarr;</a></span></h2>
591
-
592
- <p>Code is located at <a
593
- href="https://github.com/ruby-prof/ruby-prof">github.com/ruby-prof/ruby-prof</a></p>
594
-
595
- <p>Google group/mailing list: <a
596
- href="http://groups.google.com/group/ruby-optimization">groups.google.com/group/ruby-optimization</a>
597
- or start a github issue.</p>
598
- </main>
599
-
600
-
601
-
602
- <footer id="validator-badges" role="contentinfo">
603
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
604
- <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
605
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
606
- </footer>
607
-