ruby-prof 0.15.8 → 0.15.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +5 -0
  3. data/README.rdoc +187 -185
  4. data/doc/LICENSE.html +114 -0
  5. data/doc/README_rdoc.html +544 -0
  6. data/doc/Rack.html +95 -0
  7. data/doc/Rack/RubyProf.html +223 -0
  8. data/doc/RubyProf.html +961 -0
  9. data/doc/RubyProf/AbstractPrinter.html +546 -0
  10. data/doc/RubyProf/AggregateCallInfo.html +551 -0
  11. data/doc/RubyProf/CallInfo.html +639 -0
  12. data/doc/RubyProf/CallInfoPrinter.html +120 -0
  13. data/doc/RubyProf/CallInfoVisitor.html +198 -0
  14. data/doc/RubyProf/CallStackPrinter.html +1121 -0
  15. data/doc/RubyProf/CallTreePrinter.html +359 -0
  16. data/doc/RubyProf/Cmd.html +631 -0
  17. data/doc/RubyProf/DotPrinter.html +257 -0
  18. data/doc/RubyProf/FlatPrinter.html +163 -0
  19. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +208 -0
  20. data/doc/RubyProf/GraphHtmlPrinter.html +552 -0
  21. data/doc/RubyProf/GraphPrinter.html +139 -0
  22. data/doc/RubyProf/MethodInfo.html +745 -0
  23. data/doc/RubyProf/MultiPrinter.html +358 -0
  24. data/doc/RubyProf/Profile.html +713 -0
  25. data/doc/RubyProf/ProfileTask.html +490 -0
  26. data/doc/RubyProf/Thread.html +268 -0
  27. data/doc/created.rid +13 -13
  28. data/doc/examples/flat_txt.html +138 -0
  29. data/doc/examples/graph_html.html +909 -0
  30. data/doc/examples/graph_txt.html +247 -0
  31. data/doc/images/add.png +0 -0
  32. data/doc/images/arrow_up.png +0 -0
  33. data/doc/images/brick.png +0 -0
  34. data/doc/images/brick_link.png +0 -0
  35. data/doc/images/bug.png +0 -0
  36. data/doc/images/bullet_black.png +0 -0
  37. data/doc/images/bullet_toggle_minus.png +0 -0
  38. data/doc/images/bullet_toggle_plus.png +0 -0
  39. data/doc/images/date.png +0 -0
  40. data/doc/images/delete.png +0 -0
  41. data/doc/images/find.png +0 -0
  42. data/doc/images/macFFBgHack.png +0 -0
  43. data/doc/images/package.png +0 -0
  44. data/doc/images/page_green.png +0 -0
  45. data/doc/images/page_white_text.png +0 -0
  46. data/doc/images/page_white_width.png +0 -0
  47. data/doc/images/plugin.png +0 -0
  48. data/doc/images/ruby.png +0 -0
  49. data/doc/images/tag_blue.png +0 -0
  50. data/doc/images/tag_green.png +0 -0
  51. data/doc/images/transparent.png +0 -0
  52. data/doc/images/wrench.png +0 -0
  53. data/doc/images/wrench_orange.png +0 -0
  54. data/doc/images/zoom.png +0 -0
  55. data/doc/index.html +571 -0
  56. data/doc/js/navigation.js.gz +0 -0
  57. data/doc/js/search_index.js +1 -1
  58. data/doc/js/search_index.js.gz +0 -0
  59. data/doc/js/searcher.js.gz +0 -0
  60. data/doc/table_of_contents.html +893 -0
  61. data/examples/flat.txt +50 -55
  62. data/examples/graph.html +823 -823
  63. data/examples/graph.txt +139 -170
  64. data/ext/ruby_prof/extconf.rb +6 -1
  65. data/lib/ruby-prof/aggregate_call_info.rb +17 -11
  66. data/lib/ruby-prof/call_info.rb +2 -17
  67. data/lib/ruby-prof/method_info.rb +6 -22
  68. data/lib/ruby-prof/printers/graph_html_printer.rb +0 -2
  69. data/lib/ruby-prof/printers/graph_printer.rb +4 -6
  70. data/lib/ruby-prof/rack.rb +7 -0
  71. data/lib/ruby-prof/thread.rb +0 -4
  72. data/lib/ruby-prof/version.rb +1 -1
  73. data/ruby-prof.gemspec +1 -1
  74. data/test/basic_test.rb +26 -26
  75. data/test/issue137_test.rb +63 -0
  76. data/test/measure_allocations_test.rb +4 -3
  77. data/test/measure_cpu_time_test.rb +6 -6
  78. data/test/measure_process_time_test.rb +8 -8
  79. data/test/pause_resume_test.rb +9 -9
  80. data/test/printers_test.rb +1 -1
  81. data/test/printing_recursive_graph_test.rb +127 -0
  82. data/test/rack_test.rb +49 -1
  83. data/test/recursive_test.rb +41 -37
  84. data/test/test_helper.rb +93 -0
  85. metadata +59 -5
@@ -0,0 +1,247 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>graph - 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-Graph+Profiles">Graph Profiles</a>
59
+ <li><a href="#label-Overview">Overview</a>
60
+ <li><a href="#label-Parents">Parents</a>
61
+ <li><a href="#label-Children">Children</a>
62
+ </ul>
63
+ </div>
64
+
65
+
66
+ <div id="project-metadata">
67
+ <div id="fileindex-section" class="nav-section">
68
+ <h3>Pages</h3>
69
+
70
+ <ul class="link-list">
71
+
72
+ <li><a href="../LICENSE.html">LICENSE</a>
73
+
74
+ <li><a href="../README_rdoc.html">README</a>
75
+
76
+ <li><a href="../examples/flat_txt.html">flat</a>
77
+
78
+ <li><a href="../examples/graph_html.html">graph.html</a>
79
+
80
+ <li><a href="../examples/graph_txt.html">graph</a>
81
+
82
+ </ul>
83
+ </div>
84
+
85
+ </div>
86
+ </nav>
87
+
88
+ <main role="main" aria-label="Page examples/graph.txt">
89
+
90
+ <h1 id="label-Graph+Profiles">Graph Profiles<span><a href="#label-Graph+Profiles">&para;</a> <a href="#top">&uarr;</a></span></h1>
91
+
92
+ <p>Graph profiles show how long each method runs, which methods call it and
93
+ which methods it calls.</p>
94
+
95
+ <p>As an example, here is the output from running printers_test.rb:</p>
96
+
97
+ <p>Measure Mode: wall_time Thread ID: 70310439543100 Fiber ID: 70310456289620
98
+ Total Time: 0.05264616012573242 Sort by: total_time</p>
99
+
100
+ <pre>%total %self total self wait child calls name</pre>
101
+ <hr>
102
+
103
+ <pre>100.00% 0.01% 0.053 0.000 0.000 0.053 1 PrintersTest#setup
104
+ 0.053 0.000 0.000 0.053 1/1 Object#run_primes</pre>
105
+ <hr>
106
+
107
+ <pre> 0.053 0.000 0.000 0.053 1/1 PrintersTest#setup
108
+ 99.99% 0.01% 0.053 0.000 0.000 0.053 1 Object#run_primes
109
+ 0.052 0.000 0.000 0.052 1/1 Object#find_primes
110
+ 0.001 0.000 0.000 0.001 1/1 Object#make_random_array
111
+ 0.000 0.000 0.000 0.000 1/1 Object#find_largest</pre>
112
+ <hr>
113
+
114
+ <pre> 0.052 0.000 0.000 0.052 1/1 Object#run_primes
115
+ 98.35% 0.00% 0.052 0.000 0.000 0.052 1 Object#find_primes
116
+ 0.052 0.000 0.000 0.051 1/1 Array#select</pre>
117
+ <hr>
118
+
119
+ <pre> 0.052 0.000 0.000 0.051 1/1 Object#find_primes
120
+ 98.34% 0.61% 0.052 0.000 0.000 0.051 1 Array#select
121
+ 0.051 0.000 0.000 0.051 1000/1000 Object#is_prime</pre>
122
+ <hr>
123
+
124
+ <pre> 0.051 0.000 0.000 0.051 1000/1000 Array#select
125
+ 97.74% 0.93% 0.051 0.000 0.000 0.051 1000 Object#is_prime
126
+ 0.051 0.051 0.000 0.000 1000/1001 Integer#upto</pre>
127
+ <hr>
128
+
129
+ <pre> 0.000 0.000 0.000 0.000 1/1001 Object#find_largest
130
+ 0.051 0.051 0.000 0.000 1000/1001 Object#is_prime
131
+ 96.91% 96.91% 0.051 0.051 0.000 0.000 1001 Integer#upto</pre>
132
+ <hr>
133
+
134
+ <pre> 0.001 0.000 0.000 0.001 1/1 Object#run_primes
135
+ 1.51% 0.00% 0.001 0.000 0.000 0.001 1 Object#make_random_array
136
+ 0.001 0.000 0.000 0.000 1/1 Array#each_index
137
+ 0.000 0.000 0.000 0.000 1/1 Class#new</pre>
138
+ <hr>
139
+
140
+ <pre> 0.001 0.000 0.000 0.000 1/1 Object#make_random_array
141
+ 1.50% 0.56% 0.001 0.000 0.000 0.000 1 Array#each_index
142
+ 0.000 0.000 0.000 0.000 1000/1000 Kernel#rand</pre>
143
+ <hr>
144
+
145
+ <pre> 0.000 0.000 0.000 0.000 1000/1000 Array#each_index
146
+ 0.94% 0.72% 0.000 0.000 0.000 0.000 1000 Kernel#rand
147
+ 0.000 0.000 0.000 0.000 1000/1000 Kernel#respond_to_missing?</pre>
148
+ <hr>
149
+
150
+ <pre> 0.000 0.000 0.000 0.000 1000/1000 Kernel#rand
151
+ 0.22% 0.22% 0.000 0.000 0.000 0.000 1000 Kernel#respond_to_missing?</pre>
152
+ <hr>
153
+
154
+ <pre> 0.000 0.000 0.000 0.000 1/1 Object#run_primes
155
+ 0.12% 0.02% 0.000 0.000 0.000 0.000 1 Object#find_largest
156
+ 0.000 0.000 0.000 0.000 1/1001 Integer#upto
157
+ 0.000 0.000 0.000 0.000 1/1 Array#first</pre>
158
+ <hr>
159
+
160
+ <pre> 0.000 0.000 0.000 0.000 1/1 Object#make_random_array
161
+ 0.01% 0.00% 0.000 0.000 0.000 0.000 1 Class#new
162
+ 0.000 0.000 0.000 0.000 1/1 Array#initialize</pre>
163
+ <hr>
164
+
165
+ <pre> 0.000 0.000 0.000 0.000 1/1 Class#new
166
+ 0.01% 0.01% 0.000 0.000 0.000 0.000 1 Array#initialize</pre>
167
+ <hr>
168
+
169
+ <pre> 0.000 0.000 0.000 0.000 1/1 Object#find_largest
170
+ 0.00% 0.00% 0.000 0.000 0.000 0.000 1 Array#first</pre>
171
+
172
+ <h2 id="label-Overview">Overview<span><a href="#label-Overview">&para;</a> <a href="#top">&uarr;</a></span></h2>
173
+
174
+ <p>Dashed lines divide the report into entries, with one entry per method.
175
+ Entries are sorted by total time which is the time spent in the method plus
176
+ its children.</p>
177
+
178
+ <p>Each entry has a primary line demarked by values in the %total and %self
179
+ columns. The primary line represents the method being profiled. Lines
180
+ above it are the methods that called this method (parents) while the lines
181
+ below it are the methods it called (children).</p>
182
+
183
+ <p>All values are in seconds. For the primary line, the columns represent:</p>
184
+
185
+ <pre>%total - The percentage of time spent in this method and its children
186
+ %self - The percentage of time spent in this method
187
+ total - The time spent in this method and its children.
188
+ self - The time spent in this method.
189
+ wait - The time spent waiting for other threads in this method.
190
+ child - The time spent in this method&#39;s children.
191
+ calls - The number of times this method was called.
192
+ name - The name of the method.</pre>
193
+
194
+ <p>The interpretation of method names is:</p>
195
+
196
+ <pre>MyObject#test - An instance method &quot;test&quot; of the class &quot;MyObject&quot;
197
+ &lt;Object:MyObject&gt;#test - The &lt;&gt; characters indicate a singleton method on a singleton class.</pre>
198
+
199
+ <p>For example, we see that 97.74% of the time was spent in Object#is_prime
200
+ and its children. Of that time, almost everything was contributed by
201
+ Integer#upto. Overall, Object#is_prime was called 1001 times and 1000 of
202
+ those calls were made by Object#is_prime.</p>
203
+
204
+ <h2 id="label-Parents">Parents<span><a href="#label-Parents">&para;</a> <a href="#top">&uarr;</a></span></h2>
205
+
206
+ <p>In each entry, the lines above the primary line are the methods that called
207
+ the current method. If the current method is a root method then no parents
208
+ are shown.</p>
209
+
210
+ <p>For parent lines, the columns represent:</p>
211
+
212
+ <pre>total - The time spent in the current method and its children on behalf of the parent method.
213
+ self - The time spent in this method on behalf of the parent method.
214
+ child - The time spent in this method&#39;s children on behalf of the parent.
215
+ wait - The time spent waiting for other threads in this method&#39;s children on behalf of the parent.
216
+ calls - The number of times the parent method called the current method vs. the total number of calls of the current method.</pre>
217
+
218
+ <p>Looking at the main entry for Integer#upto, we see that it was called 1000
219
+ times from Object#is_prime and 1 time from find_largest.</p>
220
+
221
+ <h2 id="label-Children">Children<span><a href="#label-Children">&para;</a> <a href="#top">&uarr;</a></span></h2>
222
+
223
+ <p>In each entry, the lines below the primary line are the methods that the
224
+ current method called. If the current method is a leaf method then no
225
+ children are shown.</p>
226
+
227
+ <p>For children lines, the columns represent:</p>
228
+
229
+ <pre>total - The time spent in the child, and its descendants, on behalf of the current method
230
+ self - The time spent in the child on behalf of the current method.
231
+ wait - The time spent waiting for other threads in the child&#39;s and its descendants on behalf of the current method.
232
+ child - The time spent in the child&#39;s descendants on behalf of the current method.
233
+ calls - The number of times the child method was called by the current method vs. the total number of calls of the child method.</pre>
234
+
235
+ <p>If we look at the main entry for Objext#run_primes, we see that it called
236
+ three other methods - Object#find_primes, Object#make_random_array and
237
+ Object#find_largest.</p>
238
+ </main>
239
+
240
+
241
+
242
+ <footer id="validator-badges" role="contentinfo">
243
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
244
+ <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
245
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
246
+ </footer>
247
+
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,571 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>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
+
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
+ <div id="project-metadata">
55
+ <div id="fileindex-section" class="nav-section">
56
+ <h3>Pages</h3>
57
+
58
+ <ul class="link-list">
59
+
60
+ <li><a href="./LICENSE.html">LICENSE</a>
61
+
62
+ <li><a href="./README_rdoc.html">README</a>
63
+
64
+ <li><a href="./examples/flat_txt.html">flat</a>
65
+
66
+ <li><a href="./examples/graph_html.html">graph.html</a>
67
+
68
+ <li><a href="./examples/graph_txt.html">graph</a>
69
+
70
+ </ul>
71
+ </div>
72
+
73
+ <div id="classindex-section" class="nav-section">
74
+ <h3>Class and Module Index</h3>
75
+
76
+ <ul class="link-list">
77
+
78
+ <li><a href="./Rack.html">Rack</a>
79
+
80
+ <li><a href="./Rack/RubyProf.html">Rack::RubyProf</a>
81
+
82
+ <li><a href="./RubyProf.html">RubyProf</a>
83
+
84
+ <li><a href="./RubyProf/AbstractPrinter.html">RubyProf::AbstractPrinter</a>
85
+
86
+ <li><a href="./RubyProf/AggregateCallInfo.html">RubyProf::AggregateCallInfo</a>
87
+
88
+ <li><a href="./RubyProf/CallInfo.html">RubyProf::CallInfo</a>
89
+
90
+ <li><a href="./RubyProf/CallInfoPrinter.html">RubyProf::CallInfoPrinter</a>
91
+
92
+ <li><a href="./RubyProf/CallInfoVisitor.html">RubyProf::CallInfoVisitor</a>
93
+
94
+ <li><a href="./RubyProf/CallStackPrinter.html">RubyProf::CallStackPrinter</a>
95
+
96
+ <li><a href="./RubyProf/CallTreePrinter.html">RubyProf::CallTreePrinter</a>
97
+
98
+ <li><a href="./RubyProf/Cmd.html">RubyProf::Cmd</a>
99
+
100
+ <li><a href="./RubyProf/DotPrinter.html">RubyProf::DotPrinter</a>
101
+
102
+ <li><a href="./RubyProf/FlatPrinter.html">RubyProf::FlatPrinter</a>
103
+
104
+ <li><a href="./RubyProf/FlatPrinterWithLineNumbers.html">RubyProf::FlatPrinterWithLineNumbers</a>
105
+
106
+ <li><a href="./RubyProf/GraphHtmlPrinter.html">RubyProf::GraphHtmlPrinter</a>
107
+
108
+ <li><a href="./RubyProf/GraphPrinter.html">RubyProf::GraphPrinter</a>
109
+
110
+ <li><a href="./RubyProf/MethodInfo.html">RubyProf::MethodInfo</a>
111
+
112
+ <li><a href="./RubyProf/MultiPrinter.html">RubyProf::MultiPrinter</a>
113
+
114
+ <li><a href="./RubyProf/Profile.html">RubyProf::Profile</a>
115
+
116
+ <li><a href="./RubyProf/ProfileTask.html">RubyProf::ProfileTask</a>
117
+
118
+ <li><a href="./RubyProf/Thread.html">RubyProf::Thread</a>
119
+
120
+ </ul>
121
+ </div>
122
+
123
+ </div>
124
+ </nav>
125
+
126
+ <main role="main">
127
+
128
+
129
+ <h1 id="label-ruby-prof">ruby-prof<span><a href="#label-ruby-prof">&para;</a> <a href="#top">&uarr;</a></span></h1>
130
+
131
+ <p><a href="https://travis-ci.org/ruby-prof/ruby-prof"><img
132
+ src="https://travis-ci.org/ruby-prof/ruby-prof.png?branch=master"
133
+ alt="Build Status" /></a></p>
134
+
135
+ <h2 id="label-Overview">Overview<span><a href="#label-Overview">&para;</a> <a href="#top">&uarr;</a></span></h2>
136
+
137
+ <p>ruby-prof is a fast code profiler for MRI Ruby. Its features include:</p>
138
+ <ul><li>
139
+ <p>Speed - it is a C extension and therefore many times faster than the
140
+ standard Ruby profiler.</p>
141
+ </li><li>
142
+ <p>Modes - Ruby prof can measure a number of different parameters, including
143
+ call times, memory usage and object allocations.</p>
144
+ </li><li>
145
+ <p>Reports - can generate text and cross-referenced html reports</p>
146
+ <ul><li>
147
+ <p>Flat Profiles - similar to the reports generated by the standard Ruby
148
+ profiler</p>
149
+ </li><li>
150
+ <p>Graph profiles - similar to GProf, these show how long a method runs, which
151
+ methods call it and which methods it calls.</p>
152
+ </li><li>
153
+ <p>Call tree profiles - outputs results in the calltree format suitable for
154
+ the KCacheGrind profiling tool.</p>
155
+ </li><li>
156
+ <p>Many more – see reports section of this README.</p>
157
+ </li></ul>
158
+ </li><li>
159
+ <p>Threads - supports profiling multiple threads simultaneously</p>
160
+ </li></ul>
161
+
162
+ <h2 id="label-Requirements">Requirements<span><a href="#label-Requirements">&para;</a> <a href="#top">&uarr;</a></span></h2>
163
+
164
+ <p>ruby-prof requires Ruby 1.9.3 or higher. Please note some ruby releases
165
+ have known bugs which cause ruby-prof problems, like incorrect
166
+ measurements. We suggest to use the latest minor patch level release if
167
+ possible. In particular, on the 2.1 branch of ruby you should use 2.1.7.</p>
168
+
169
+ <p>If you are running Linux or Unix you&#39;ll need a C compiler so the
170
+ extension can be compiled when it is installed.</p>
171
+
172
+ <p>If you are running Windows, then you may need to install the Windows
173
+ specific RubyGem which includes an already built extension (see Install
174
+ section).</p>
175
+
176
+ <h2 id="label-Install">Install<span><a href="#label-Install">&para;</a> <a href="#top">&uarr;</a></span></h2>
177
+
178
+ <p>The easiest way to install ruby-prof is by using Ruby Gems. To install:</p>
179
+
180
+ <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>
181
+ </pre>
182
+
183
+ <p>If you&#39;re on windows then please install the devkit first so that it
184
+ can compile.</p>
185
+
186
+ <h2 id="label-Usage">Usage<span><a href="#label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>
187
+
188
+ <p>There are two ways of running ruby-prof, via the command line or via its
189
+ API.</p>
190
+
191
+ <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>
192
+
193
+ <p>The first is to use ruby-prof to run the Ruby program you want to profile.
194
+ For more information refer to the documentation of the ruby-prof command.</p>
195
+
196
+ <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>
197
+
198
+ <p>The second way is to use the ruby-prof API to profile particular segments
199
+ of code.</p>
200
+
201
+ <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
202
+
203
+ <span class="ruby-comment"># profile the code</span>
204
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
205
+ <span class="ruby-comment"># ... code to profile ...</span>
206
+ <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
207
+
208
+ <span class="ruby-comment"># print a flat profile to text</span>
209
+ <span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">FlatPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
210
+ <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>)
211
+ </pre>
212
+
213
+ <p>Alternatively, you can use a block to tell ruby-prof what to profile:</p>
214
+
215
+ <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
216
+
217
+ <span class="ruby-comment"># profile the code</span>
218
+ <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
219
+ <span class="ruby-comment"># ... code to profile ...</span>
220
+ <span class="ruby-keyword">end</span>
221
+
222
+ <span class="ruby-comment"># print a graph profile to text</span>
223
+ <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>)
224
+ <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, {})
225
+ </pre>
226
+
227
+ <p>ruby-prof also supports pausing and resuming profiling runs.</p>
228
+
229
+ <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
230
+
231
+ <span class="ruby-comment"># profile the code</span>
232
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
233
+ <span class="ruby-comment"># ... code to profile ...</span>
234
+
235
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">pause</span>
236
+ <span class="ruby-comment"># ... other code ...</span>
237
+
238
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span>
239
+ <span class="ruby-comment"># ... code to profile ...</span>
240
+ <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
241
+ </pre>
242
+
243
+ <p>Note that resume will automatically call start if a profiling run has not
244
+ yet started. In addition, resume can also take a block:</p>
245
+
246
+ <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
247
+
248
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span> <span class="ruby-keyword">do</span>
249
+ <span class="ruby-comment"># ... code to profile...</span>
250
+ <span class="ruby-keyword">end</span>
251
+
252
+ <span class="ruby-identifier">data</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
253
+ </pre>
254
+
255
+ <p>With this usage, resume will automatically call pause at the end of the
256
+ block.</p>
257
+
258
+ <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>
259
+
260
+ <p>ruby-prof supports eliminating specific methods and threads from profiling
261
+ results. This is useful for reducing connectivity in the call graph, making
262
+ it easier to identify the source of performance problems when using a graph
263
+ printer.</p>
264
+
265
+ <p>For example, consider <code>Integer#times</code>: it&#39;s hardly ever
266
+ useful to know how much time is spent in the method itself. We&#39;re much
267
+ more interested in how much the passed in block contributes to the time
268
+ spent in the method which contains the <code>Integer#times</code> call.</p>
269
+
270
+ <p>Methods are eliminated from the collected data by calling
271
+ <code>eliminate_methods!</code> on the profiling result, before submitting
272
+ it to a printer.</p>
273
+
274
+ <pre class="ruby"><span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
275
+ <span class="ruby-identifier">result</span>.<span class="ruby-identifier">eliminate_methods!</span>([<span class="ruby-node">/Integer#times/</span>])
276
+ </pre>
277
+
278
+ <p>The argument given to <code>eliminate_methods!</code> is either an array of
279
+ regular expressions, or the name of a file containing a list of regular
280
+ expressions (line separated text).</p>
281
+
282
+ <p>After eliminating methods the resulting profile will appear exactly as if
283
+ those methods had been inlined at their call sites.</p>
284
+
285
+ <p>In a similar manner, threads can be excluded so they are not profiled at
286
+ all. To do this, pass an array of threads to exclude to ruby-prof:</p>
287
+
288
+ <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> ]
289
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
290
+ </pre>
291
+
292
+ <p>Note that the excluded threads must be specified <strong>before</strong>
293
+ profiling.</p>
294
+
295
+ <h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">&para;</a> <a href="#top">&uarr;</a></span></h2>
296
+
297
+ <p>To profile a Rails application it is vital to run it using production like
298
+ settings (cache classes, cache view lookups, etc.). Otherwise, Rail&#39;s
299
+ dependency loading code will overwhelm any time spent in the application
300
+ itself (our tests show that Rails dependency loading causes a roughly 6x
301
+ slowdown). The best way to do this is create a new Rails environment,
302
+ profile.rb.</p>
303
+
304
+ <p>So to profile Rails:</p>
305
+ <ol><li>
306
+ <p>Create a new profile.rb environment. Make sure to turn on
307
+ <code>cache_classes</code> and <code>cache_template_loading</code>.
308
+ Otherwise your profiling results will be overwhelemed by the time Rails
309
+ spends loading required files. You should likely turn off caching.</p>
310
+ </li><li>
311
+ <p>Add the ruby-prof to your gemfile:</p>
312
+
313
+ <pre class="ruby"><span class="ruby-identifier">group</span> :<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
314
+ <span class="ruby-identifier">gem</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
315
+ <span class="ruby-keyword">end</span>
316
+ </pre>
317
+ </li><li>
318
+ <p>Add the ruby prof rack adapter to your middleware stack. One way to do
319
+ this is by adding the following code to <code>config.ru</code>:</p>
320
+
321
+ <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>
322
+ <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>
323
+ <span class="ruby-keyword">end</span>
324
+ </pre>
325
+
326
+ <p>The path is where you want profiling results to be stored. By default the
327
+ rack adapter will generate a html call graph report and flat text report.</p>
328
+ </li><li>
329
+ <p>Now make a request to your running server. New profiling information will
330
+ be generated for each request. Note that each request will overwrite the
331
+ profiling reports created by the previous request!</p>
332
+ </li></ol>
333
+
334
+ <h2 id="label-Reports">Reports<span><a href="#label-Reports">&para;</a> <a href="#top">&uarr;</a></span></h2>
335
+
336
+ <p>ruby-prof can generate a number of different reports:</p>
337
+ <ul><li>
338
+ <p>Flat Reports</p>
339
+ </li><li>
340
+ <p>Graph Reports</p>
341
+ </li><li>
342
+ <p>HTML Graph Reports</p>
343
+ </li><li>
344
+ <p>Call graphs</p>
345
+ </li><li>
346
+ <p>Call stack reports</p>
347
+ </li><li>
348
+ <p>More!</p>
349
+ </li></ul>
350
+
351
+ <p>Flat profiles show the overall time spent in each method. They are a good
352
+ way of quickly identifying which methods take the most time. An example of
353
+ a flat profile and an explanation can be found in <a
354
+ href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/flat.txt">examples/flat.txt</a>.</p>
355
+
356
+ <p>There are several varieties of these - run <code>ruby-prof --help</code></p>
357
+
358
+ <p>Graph profiles also show the overall time spent in each method. In
359
+ addition, they also show which methods call the current method and which
360
+ methods its calls. Thus they are good for understanding how methods gets
361
+ called and provide insight into the flow of your program. An example text
362
+ graph profile is located at <a
363
+ href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.txt">examples/graph.txt</a>.</p>
364
+
365
+ <p>HTML Graph profiles are the same as graph profiles, except output is
366
+ generated in hyper-linked HTML. Since graph profiles can be quite large,
367
+ the embedded links make it much easier to navigate the results. An example
368
+ html graph profile is located at <a
369
+ href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.html">examples/graph.html</a>.</p>
370
+
371
+ <p>Call graphs output results in the calltree profile format which is used by
372
+ KCachegrind. Call graph support was generously donated by Carl Shimer. More
373
+ information about the format can be found at the <a
374
+ href="http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindCalltreeFormat">KCachegrind</a>
375
+ site.</p>
376
+
377
+ <p>Call stack reports produce a HTML visualization of the time spent in each
378
+ execution path of the profiled code. An example can be found at <a
379
+ href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/stack.html">examples/stack.html</a>.</p>
380
+
381
+ <p>Another good example: <a
382
+ href="http://twitpic.com/28z94a">twitpic.com/28z94a</a></p>
383
+
384
+ <p>Finally, there&#39;s a so called MultiPrinter which can generate several
385
+ reports in one profiling run. See <a
386
+ href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/multi.stack.html">examples/multi.stack.html</a>.</p>
387
+
388
+ <p>There is also a graphviz .dot visualiser.</p>
389
+
390
+ <h2 id="label-Printers">Printers<span><a href="#label-Printers">&para;</a> <a href="#top">&uarr;</a></span></h2>
391
+
392
+ <p>Reports are created by printers. Supported printers include:</p>
393
+ <dl class="rdoc-list note-list"><dt><a href="RubyProf/FlatPrinter.html">RubyProf::FlatPrinter</a>
394
+ <dd>
395
+ <p>Creates a flat report in text format</p>
396
+ </dd><dt><a href="RubyProf/FlatPrinterWithLineNumbers.html">RubyProf::FlatPrinterWithLineNumbers</a>
397
+ <dd>
398
+ <p>Same as above but more verbose</p>
399
+ </dd><dt><a href="RubyProf/GraphPrinter.html">RubyProf::GraphPrinter</a>
400
+ <dd>
401
+ <p>Creates a call graph report in text format</p>
402
+ </dd><dt><a href="RubyProf/GraphHtmlPrinter.html">RubyProf::GraphHtmlPrinter</a>
403
+ <dd>
404
+ <p>Creates a call graph report in HTML (separate files per thread)</p>
405
+ </dd><dt><a href="RubyProf/DotPrinter.html">RubyProf::DotPrinter</a>
406
+ <dd>
407
+ <p>Creates a call graph report in GraphViz&#39;s DOT format which can be
408
+ converted to an image</p>
409
+ </dd><dt><a href="RubyProf/CallTreePrinter.html">RubyProf::CallTreePrinter</a>
410
+ <dd>
411
+ <p>Creates a call tree report compatible with KCachegrind</p>
412
+ </dd><dt><a href="RubyProf/CallStackPrinter.html">RubyProf::CallStackPrinter</a>
413
+ <dd>
414
+ <p>Creates a HTML visualization of the Ruby stack</p>
415
+ </dd><dt><a href="RubyProf/MultiPrinter.html">RubyProf::MultiPrinter</a>
416
+ <dd>
417
+ <p>Uses the other printers to create several reports in one profiling run</p>
418
+ </dd></dl>
419
+
420
+ <p>To use a printer:</p>
421
+
422
+ <pre class="ruby"><span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
423
+ <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>)
424
+ <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, :<span class="ruby-identifier">min_percent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>)
425
+ </pre>
426
+
427
+ <p>The first parameter is any writable IO object such as <code>STDOUT</code>
428
+ or a file. The second parameter, specifies the minimum percentage a method
429
+ must take to be printed. Percentages should be specified as integers in
430
+ the range 0 to 100. For more information please see the documentation for
431
+ the different printers.</p>
432
+
433
+ <p>The other option is <code>:print_file =&gt; true</code> (default false),
434
+ which adds the filename to the output (GraphPrinter only).</p>
435
+
436
+ <p><code>MultiPrinter</code> differs from the other printers in that it
437
+ requires a directory path and a basename for the files it produces.</p>
438
+
439
+ <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>)
440
+ <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>)
441
+ </pre>
442
+
443
+ <h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">&para;</a> <a href="#top">&uarr;</a></span></h2>
444
+
445
+ <p>Depending on the mode and platform, ruby-prof can measure various aspects
446
+ of a Ruby program. Supported measurements include:</p>
447
+ <dl class="rdoc-list note-list"><dt>RubyProf::WALL_TIME
448
+ <dd>
449
+ <p>Wall time measures the real-world time elapsed between any two moments. If
450
+ there are other processes concurrently running on the system that use
451
+ significant CPU or disk time during a profiling run then the reported
452
+ results will be larger than expected.</p>
453
+ </dd><dt>RubyProf::PROCESS_TIME
454
+ <dd>
455
+ <p>Process time measures the time used by a process between any two moments.
456
+ It is unaffected by other processes concurrently running on the system.
457
+ Note that Windows does not support measuring process times.</p>
458
+ </dd><dt>RubyProf::CPU_TIME
459
+ <dd>
460
+ <p>CPU time uses the CPU clock counter to measure time. The returned values
461
+ are dependent on the correctly setting the CPU&#39;s frequency. This mode
462
+ is only supported on Pentium or PowerPC platforms (linux only).</p>
463
+ </dd><dt>RubyProf::ALLOCATIONS
464
+ <dd>
465
+ <p>Object allocation reports show how many objects each method in a program
466
+ allocates. This support was added by Sylvain Joyeux and requires a patched
467
+ Ruby interpreter. See below.</p>
468
+ </dd><dt>RubyProf::MEMORY
469
+ <dd>
470
+ <p>Memory usage reports show how much memory each method in a program uses.
471
+ This support was added by Alexander Dymo and requires a patched Ruby
472
+ interpreter. See below.</p>
473
+ </dd><dt>RubyProf::GC_TIME
474
+ <dd>
475
+ <p>Garbage collection time reports how much time is spent in Ruby&#39;s
476
+ garbage collector during a profiling session. This support was added by
477
+ Jeremy Kemper and requires a patched Ruby interpreter. See below.</p>
478
+ </dd><dt>RubyProf::GC_RUNS
479
+ <dd>
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
+ </dd></dl>
484
+
485
+ <p>All of the patches to Ruby are included in the railsexpress patchsets for
486
+ rvm, see <a
487
+ href="https://github.com/skaes/rvm-patchsets">github.com/skaes/rvm-patchsets</a></p>
488
+
489
+ <p>To set the measurement:</p>
490
+
491
+ <pre class="ruby"><span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">WALL_TIME</span>
492
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">PROCESS_TIME</span>
493
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">CPU_TIME</span>
494
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">ALLOCATIONS</span>
495
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">MEMORY</span>
496
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GC_TIME</span>
497
+ <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GC_RUNS</span>
498
+ </pre>
499
+
500
+ <p>The default value is <code>RubyProf::WALL_TIME</code>.</p>
501
+
502
+ <p>You may also specify the measure mode by using the
503
+ <code>RUBY_PROF_MEASURE_MODE</code> environment variable:</p>
504
+
505
+ <pre class="ruby"><span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">wall</span>
506
+ <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">process</span>
507
+ <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">cpu</span>
508
+ <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">allocations</span>
509
+ <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">memory</span>
510
+ <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">gc_time</span>
511
+ <span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">gc_runs</span>
512
+ </pre>
513
+
514
+ <p>On Linux, process time is measured using the clock method provided by the C
515
+ runtime library. Note that the clock method does not report time spent in
516
+ the kernel or child processes and therefore does not measure time spent in
517
+ methods such as Kernel.sleep method. If you need to measure these values,
518
+ then use wall time. Wall time is measured using the gettimeofday kernel
519
+ method.</p>
520
+
521
+ <p>If you set the clock mode to <code>PROCESS_TIME</code>, then timings are
522
+ read using the clock method provided by the C runtime library. Note
523
+ though, these values are wall times on Windows and not process times like
524
+ on Linux. Wall time is measured using the GetLocalTime API.</p>
525
+
526
+ <p>If you use wall time, the results will be affected by other processes
527
+ running on your computer, network delays, disk access, etc. As result, for
528
+ the best results, try to make sure your computer is only performing your
529
+ profiling run and is otherwise quiescent.</p>
530
+
531
+ <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>
532
+
533
+ <p>Unfortunately, Ruby does not provide an internal API for detecting thread
534
+ context switches in 1.8. As a result, the timings ruby-prof reports for
535
+ each thread may be slightly inaccurate. In particular, this will happen
536
+ for newly spawned threads that go to sleep immediately (their first call).
537
+ For instance, if you use Ruby&#39;s timeout library to wait for 2 seconds,
538
+ the 2 seconds will be assigned to the foreground thread and not the newly
539
+ created background thread. These errors can largely be avoided if the
540
+ background thread performs any operation before going to sleep.</p>
541
+
542
+ <h2 id="label-Performance">Performance<span><a href="#label-Performance">&para;</a> <a href="#top">&uarr;</a></span></h2>
543
+
544
+ <p>Significant effort has been put into reducing ruby-prof&#39;s overhead as
545
+ much as possible. Our tests show that the overhead associated with
546
+ profiling code varies considerably with the code being profiled. Most
547
+ programs will run approximately twice as slow while highly recursive
548
+ programs (like the fibonacci series test) will run three times slower.</p>
549
+
550
+ <h2 id="label-License">License<span><a href="#label-License">&para;</a> <a href="#top">&uarr;</a></span></h2>
551
+
552
+ <p>See <a href="LICENSE.html">LICENSE</a> for license information.</p>
553
+
554
+ <h2 id="label-Development">Development<span><a href="#label-Development">&para;</a> <a href="#top">&uarr;</a></span></h2>
555
+
556
+ <p>Code is located at <a
557
+ href="https://github.com/ruby-prof/ruby-prof">github.com/ruby-prof/ruby-prof</a></p>
558
+
559
+ <p>Google group/mailing list: <a
560
+ href="http://groups.google.com/group/ruby-optimization">groups.google.com/group/ruby-optimization</a>
561
+ or open a github issue.</p>
562
+ </main>
563
+
564
+
565
+
566
+ <footer id="validator-badges" role="contentinfo">
567
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
568
+ <p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
569
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
570
+ </footer>
571
+