ruby-prof 0.13.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES +579 -371
  3. data/LICENSE +24 -23
  4. data/README.rdoc +5 -433
  5. data/Rakefile +98 -110
  6. data/bin/ruby-prof +328 -329
  7. data/bin/ruby-prof-check-trace +45 -0
  8. data/ext/ruby_prof/extconf.rb +16 -59
  9. data/ext/ruby_prof/rp_aggregate_call_tree.c +59 -0
  10. data/ext/ruby_prof/rp_aggregate_call_tree.h +13 -0
  11. data/ext/ruby_prof/rp_allocation.c +287 -0
  12. data/ext/ruby_prof/rp_allocation.h +31 -0
  13. data/ext/ruby_prof/rp_call_tree.c +369 -0
  14. data/ext/ruby_prof/rp_call_tree.h +43 -0
  15. data/ext/ruby_prof/rp_call_trees.c +288 -0
  16. data/ext/ruby_prof/rp_call_trees.h +28 -0
  17. data/ext/ruby_prof/rp_measure_allocations.c +50 -65
  18. data/ext/ruby_prof/rp_measure_memory.c +42 -73
  19. data/ext/ruby_prof/rp_measure_process_time.c +65 -71
  20. data/ext/ruby_prof/rp_measure_wall_time.c +64 -42
  21. data/ext/ruby_prof/rp_measurement.c +237 -0
  22. data/ext/ruby_prof/rp_measurement.h +50 -0
  23. data/ext/ruby_prof/rp_method.c +491 -420
  24. data/ext/ruby_prof/rp_method.h +62 -57
  25. data/ext/ruby_prof/rp_profile.c +908 -0
  26. data/ext/ruby_prof/rp_profile.h +35 -0
  27. data/ext/ruby_prof/rp_stack.c +212 -128
  28. data/ext/ruby_prof/rp_stack.h +53 -51
  29. data/ext/ruby_prof/rp_thread.c +362 -268
  30. data/ext/ruby_prof/rp_thread.h +39 -27
  31. data/ext/ruby_prof/ruby_prof.c +52 -695
  32. data/ext/ruby_prof/ruby_prof.h +26 -55
  33. data/ext/ruby_prof/vc/ruby_prof.sln +28 -21
  34. data/ext/ruby_prof/vc/{ruby_prof_20.vcxproj → ruby_prof.vcxproj} +56 -8
  35. data/lib/ruby-prof.rb +52 -67
  36. data/lib/ruby-prof/assets/call_stack_printer.html.erb +710 -0
  37. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  38. data/lib/ruby-prof/assets/graph_printer.html.erb +355 -0
  39. data/lib/ruby-prof/call_tree.rb +57 -0
  40. data/lib/ruby-prof/call_tree_visitor.rb +36 -0
  41. data/lib/ruby-prof/compatibility.rb +99 -169
  42. data/lib/ruby-prof/exclude_common_methods.rb +198 -0
  43. data/lib/ruby-prof/measurement.rb +17 -0
  44. data/lib/ruby-prof/method_info.rb +78 -131
  45. data/lib/ruby-prof/printers/abstract_printer.rb +137 -85
  46. data/lib/ruby-prof/printers/call_info_printer.rb +53 -41
  47. data/lib/ruby-prof/printers/call_stack_printer.rb +180 -773
  48. data/lib/ruby-prof/printers/call_tree_printer.rb +151 -92
  49. data/lib/ruby-prof/printers/dot_printer.rb +132 -132
  50. data/lib/ruby-prof/printers/flat_printer.rb +53 -69
  51. data/lib/ruby-prof/printers/graph_html_printer.rb +63 -255
  52. data/lib/ruby-prof/printers/graph_printer.rb +113 -116
  53. data/lib/ruby-prof/printers/multi_printer.rb +127 -56
  54. data/lib/ruby-prof/profile.rb +37 -77
  55. data/lib/ruby-prof/rack.rb +62 -15
  56. data/lib/ruby-prof/task.rb +147 -147
  57. data/lib/ruby-prof/thread.rb +10 -12
  58. data/lib/ruby-prof/version.rb +3 -0
  59. data/lib/unprof.rb +10 -10
  60. data/ruby-prof.gemspec +65 -61
  61. data/test/abstract_printer_test.rb +26 -0
  62. data/test/alias_test.rb +126 -0
  63. data/test/basic_test.rb +43 -128
  64. data/test/call_tree_visitor_test.rb +32 -0
  65. data/test/call_trees_test.rb +66 -0
  66. data/test/duplicate_names_test.rb +32 -32
  67. data/test/dynamic_method_test.rb +53 -74
  68. data/test/enumerable_test.rb +21 -16
  69. data/test/exceptions_test.rb +24 -16
  70. data/test/exclude_methods_test.rb +151 -0
  71. data/test/exclude_threads_test.rb +53 -54
  72. data/test/fiber_test.rb +129 -65
  73. data/test/gc_test.rb +90 -0
  74. data/test/inverse_call_tree_test.rb +175 -0
  75. data/test/line_number_test.rb +158 -71
  76. data/test/marshal_test.rb +113 -0
  77. data/test/measure_allocations.rb +30 -0
  78. data/test/measure_allocations_test.rb +375 -25
  79. data/test/measure_allocations_trace_test.rb +375 -0
  80. data/test/measure_memory_trace_test.rb +1101 -0
  81. data/test/measure_process_time_test.rb +785 -62
  82. data/test/measure_times.rb +56 -0
  83. data/test/measure_wall_time_test.rb +434 -254
  84. data/test/multi_printer_test.rb +71 -82
  85. data/test/no_method_class_test.rb +15 -15
  86. data/test/pause_resume_test.rb +175 -166
  87. data/test/prime.rb +54 -54
  88. data/test/prime_script.rb +6 -0
  89. data/test/printer_call_stack_test.rb +27 -0
  90. data/test/printer_call_tree_test.rb +30 -0
  91. data/test/printer_flat_test.rb +99 -0
  92. data/test/printer_graph_html_test.rb +59 -0
  93. data/test/printer_graph_test.rb +40 -0
  94. data/test/printers_test.rb +141 -257
  95. data/test/printing_recursive_graph_test.rb +81 -0
  96. data/test/profile_test.rb +16 -0
  97. data/test/rack_test.rb +93 -0
  98. data/test/recursive_test.rb +206 -215
  99. data/test/singleton_test.rb +38 -38
  100. data/test/stack_printer_test.rb +64 -78
  101. data/test/start_stop_test.rb +109 -112
  102. data/test/test_helper.rb +13 -115
  103. data/test/thread_test.rb +144 -178
  104. data/test/unique_call_path_test.rb +120 -224
  105. data/test/yarv_test.rb +56 -0
  106. metadata +77 -133
  107. data/doc/LICENSE.html +0 -155
  108. data/doc/README_rdoc.html +0 -648
  109. data/doc/Rack.html +0 -167
  110. data/doc/Rack/RubyProf.html +0 -319
  111. data/doc/RubyProf.html +0 -1000
  112. data/doc/RubyProf/AbstractPrinter.html +0 -580
  113. data/doc/RubyProf/AggregateCallInfo.html +0 -570
  114. data/doc/RubyProf/CallInfo.html +0 -512
  115. data/doc/RubyProf/CallInfoPrinter.html +0 -190
  116. data/doc/RubyProf/CallInfoVisitor.html +0 -332
  117. data/doc/RubyProf/CallStackPrinter.html +0 -1600
  118. data/doc/RubyProf/CallTreePrinter.html +0 -413
  119. data/doc/RubyProf/Cmd.html +0 -669
  120. data/doc/RubyProf/DotPrinter.html +0 -312
  121. data/doc/RubyProf/FlatPrinter.html +0 -229
  122. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +0 -267
  123. data/doc/RubyProf/GraphHtmlPrinter.html +0 -630
  124. data/doc/RubyProf/GraphPrinter.html +0 -209
  125. data/doc/RubyProf/MethodInfo.html +0 -713
  126. data/doc/RubyProf/MultiPrinter.html +0 -407
  127. data/doc/RubyProf/Profile.html +0 -821
  128. data/doc/RubyProf/ProfileTask.html +0 -532
  129. data/doc/RubyProf/Test.html +0 -578
  130. data/doc/RubyProf/Thread.html +0 -262
  131. data/doc/created.rid +0 -32
  132. data/doc/examples/flat_txt.html +0 -191
  133. data/doc/examples/graph_txt.html +0 -305
  134. data/doc/images/add.png +0 -0
  135. data/doc/images/brick.png +0 -0
  136. data/doc/images/brick_link.png +0 -0
  137. data/doc/images/bug.png +0 -0
  138. data/doc/images/bullet_black.png +0 -0
  139. data/doc/images/bullet_toggle_minus.png +0 -0
  140. data/doc/images/bullet_toggle_plus.png +0 -0
  141. data/doc/images/date.png +0 -0
  142. data/doc/images/delete.png +0 -0
  143. data/doc/images/find.png +0 -0
  144. data/doc/images/loadingAnimation.gif +0 -0
  145. data/doc/images/macFFBgHack.png +0 -0
  146. data/doc/images/package.png +0 -0
  147. data/doc/images/page_green.png +0 -0
  148. data/doc/images/page_white_text.png +0 -0
  149. data/doc/images/page_white_width.png +0 -0
  150. data/doc/images/plugin.png +0 -0
  151. data/doc/images/ruby.png +0 -0
  152. data/doc/images/tag_blue.png +0 -0
  153. data/doc/images/tag_green.png +0 -0
  154. data/doc/images/transparent.png +0 -0
  155. data/doc/images/wrench.png +0 -0
  156. data/doc/images/wrench_orange.png +0 -0
  157. data/doc/images/zoom.png +0 -0
  158. data/doc/index.html +0 -647
  159. data/doc/js/darkfish.js +0 -155
  160. data/doc/js/jquery.js +0 -18
  161. data/doc/js/navigation.js +0 -142
  162. data/doc/js/search.js +0 -94
  163. data/doc/js/search_index.js +0 -1
  164. data/doc/js/searcher.js +0 -228
  165. data/doc/rdoc.css +0 -543
  166. data/doc/table_of_contents.html +0 -462
  167. data/examples/empty.png +0 -0
  168. data/examples/flat.txt +0 -55
  169. data/examples/graph.dot +0 -106
  170. data/examples/graph.html +0 -823
  171. data/examples/graph.png +0 -0
  172. data/examples/graph.txt +0 -170
  173. data/examples/minus.png +0 -0
  174. data/examples/multi.flat.txt +0 -23
  175. data/examples/multi.graph.html +0 -906
  176. data/examples/multi.grind.dat +0 -194
  177. data/examples/multi.stack.html +0 -573
  178. data/examples/plus.png +0 -0
  179. data/examples/stack.html +0 -573
  180. data/ext/ruby_prof/rp_call_info.c +0 -407
  181. data/ext/ruby_prof/rp_call_info.h +0 -48
  182. data/ext/ruby_prof/rp_measure.c +0 -48
  183. data/ext/ruby_prof/rp_measure.h +0 -45
  184. data/ext/ruby_prof/rp_measure_cpu_time.c +0 -112
  185. data/ext/ruby_prof/rp_measure_gc_runs.c +0 -65
  186. data/ext/ruby_prof/rp_measure_gc_time.c +0 -57
  187. data/ext/ruby_prof/vc/ruby_prof_18.vcxproj +0 -108
  188. data/ext/ruby_prof/vc/ruby_prof_19.vcxproj +0 -110
  189. data/ext/ruby_prof/version.h +0 -7
  190. data/lib/ruby-prof/aggregate_call_info.rb +0 -72
  191. data/lib/ruby-prof/call_info.rb +0 -89
  192. data/lib/ruby-prof/call_info_visitor.rb +0 -44
  193. data/lib/ruby-prof/images/empty.png +0 -0
  194. data/lib/ruby-prof/images/minus.png +0 -0
  195. data/lib/ruby-prof/images/plus.png +0 -0
  196. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -57
  197. data/lib/ruby-prof/test.rb +0 -150
  198. data/test/aggregate_test.rb +0 -136
  199. data/test/call_info_test.rb +0 -78
  200. data/test/call_info_visitor_test.rb +0 -31
  201. data/test/exec_test.rb +0 -14
  202. data/test/measure_cpu_time_test.rb +0 -220
  203. data/test/measure_gc_runs_test.rb +0 -32
  204. data/test/measure_gc_time_test.rb +0 -36
  205. data/test/measure_memory_test.rb +0 -31
  206. data/test/method_elimination_test.rb +0 -84
  207. data/test/module_test.rb +0 -45
  208. data/test/stack_test.rb +0 -138
  209. data/test/test_suite.rb +0 -37
@@ -1,305 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
-
7
- <title>graph - ruby-prof</title>
8
-
9
- <link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
10
-
11
- <script type="text/javascript">
12
- var rdoc_rel_prefix = "../";
13
- </script>
14
-
15
- <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
16
- <script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
17
- <script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
18
- <script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
19
- <script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
20
- <script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
21
-
22
-
23
- <body class="file">
24
- <nav id="metadata">
25
- <nav id="home-section" class="section">
26
- <h3 class="section-header">
27
- <a href="../index.html">Home</a>
28
- <a href="../table_of_contents.html#classes">Classes</a>
29
- <a href="../table_of_contents.html#methods">Methods</a>
30
- </h3>
31
- </nav>
32
-
33
-
34
- <nav id="search-section" class="section project-section" class="initially-hidden">
35
- <form action="#" method="get" accept-charset="utf-8">
36
- <h3 class="section-header">
37
- <input type="text" name="search" placeholder="Search" id="search-field"
38
- title="Type to search, Up and Down to navigate, Enter to load">
39
- </h3>
40
- </form>
41
-
42
- <ul id="search-results" class="initially-hidden"></ul>
43
- </nav>
44
-
45
-
46
- <div id="project-metadata">
47
- <nav id="fileindex-section" class="section project-section">
48
- <h3 class="section-header">Pages</h3>
49
-
50
- <ul>
51
-
52
- <li class="file"><a href="../LICENSE.html">LICENSE</a>
53
-
54
- <li class="file"><a href="../README_rdoc.html">README</a>
55
-
56
- <li class="file"><a href="../examples/flat_txt.html">flat</a>
57
-
58
- <li class="file"><a href="../examples/graph_txt.html">graph</a>
59
-
60
- </ul>
61
- </nav>
62
-
63
- <nav id="classindex-section" class="section project-section">
64
- <h3 class="section-header">Class and Module Index</h3>
65
-
66
- <ul class="link-list">
67
-
68
- <li><a href="../RubyProf.html">RubyProf</a>
69
-
70
- <li><a href="../RubyProf/AbstractPrinter.html">RubyProf::AbstractPrinter</a>
71
-
72
- <li><a href="../RubyProf/AggregateCallInfo.html">RubyProf::AggregateCallInfo</a>
73
-
74
- <li><a href="../RubyProf/CallInfo.html">RubyProf::CallInfo</a>
75
-
76
- <li><a href="../RubyProf/CallInfoPrinter.html">RubyProf::CallInfoPrinter</a>
77
-
78
- <li><a href="../RubyProf/CallInfoVisitor.html">RubyProf::CallInfoVisitor</a>
79
-
80
- <li><a href="../RubyProf/CallStackPrinter.html">RubyProf::CallStackPrinter</a>
81
-
82
- <li><a href="../RubyProf/CallTreePrinter.html">RubyProf::CallTreePrinter</a>
83
-
84
- <li><a href="../RubyProf/Cmd.html">RubyProf::Cmd</a>
85
-
86
- <li><a href="../RubyProf/DotPrinter.html">RubyProf::DotPrinter</a>
87
-
88
- <li><a href="../RubyProf/FlatPrinter.html">RubyProf::FlatPrinter</a>
89
-
90
- <li><a href="../RubyProf/FlatPrinterWithLineNumbers.html">RubyProf::FlatPrinterWithLineNumbers</a>
91
-
92
- <li><a href="../RubyProf/GraphHtmlPrinter.html">RubyProf::GraphHtmlPrinter</a>
93
-
94
- <li><a href="../RubyProf/GraphPrinter.html">RubyProf::GraphPrinter</a>
95
-
96
- <li><a href="../RubyProf/MethodInfo.html">RubyProf::MethodInfo</a>
97
-
98
- <li><a href="../RubyProf/MultiPrinter.html">RubyProf::MultiPrinter</a>
99
-
100
- <li><a href="../RubyProf/Profile.html">RubyProf::Profile</a>
101
-
102
- <li><a href="../RubyProf/ProfileTask.html">RubyProf::ProfileTask</a>
103
-
104
- <li><a href="../RubyProf/Test.html">RubyProf::Test</a>
105
-
106
- <li><a href="../RubyProf/Thread.html">RubyProf::Thread</a>
107
-
108
- <li><a href="../Rack.html">Rack</a>
109
-
110
- <li><a href="../Rack/RubyProf.html">Rack::RubyProf</a>
111
-
112
- </ul>
113
- </nav>
114
-
115
- </div>
116
- </nav>
117
-
118
- <div id="documentation" class="description">
119
-
120
- <h1 id="label-Graph+Profiles">Graph Profiles</h1>
121
-
122
- <p>Graph profiles show how long each method runs, which methods call it and
123
- which methods it calls.</p>
124
-
125
- <p>As an example, here is the output from running printers_test.rb:</p>
126
-
127
- <p>Thread ID: 21277412</p>
128
-
129
- <pre> %total %self total self children calls Name
130
- --------------------------------------------------------------------------------
131
- 100.00% 0.00% 8.77 0.00 8.77 1 #toplevel
132
- 8.77 0.00 8.77 1/1 Object#run_primes
133
- --------------------------------------------------------------------------------
134
- 8.77 0.00 8.77 1/1 #toplevel
135
- 100.00% 0.00% 8.77 0.00 8.77 1 Object#run_primes
136
- 0.02 0.00 0.02 1/1 Object#make_random_array
137
- 2.09 0.00 2.09 1/1 Object#find_largest
138
- 6.66 0.00 6.66 1/1 Object#find_primes
139
- --------------------------------------------------------------------------------
140
- 6.63 4.06 2.56 500/501 Object#is_prime
141
- 2.09 0.00 2.09 1/501 Object#find_largest
142
- 99.48% 46.34% 8.72 4.06 4.66 501 Integer#upto
143
- 0.00 0.00 0.00 61/61 Array#[]
144
- 0.00 0.00 0.00 61/61 Fixnum#&gt;
145
- 2.09 2.09 0.00 61/61 Kernel.sleep
146
- 1.24 1.24 0.00 250862/250862 Fixnum#==
147
- 1.33 1.33 0.00 250862/250862 Fixnum#%
148
- --------------------------------------------------------------------------------
149
- 6.66 0.01 6.64 1/1 Object#find_primes
150
- 75.93% 0.17% 6.66 0.01 6.64 1 Array#select
151
- 6.64 0.01 6.63 500/500 Object#is_prime
152
- --------------------------------------------------------------------------------
153
- 6.66 0.00 6.66 1/1 Object#run_primes
154
- 75.93% 0.00% 6.66 0.00 6.66 1 Object#find_primes
155
- 6.66 0.01 6.64 1/1 Array#select
156
- --------------------------------------------------------------------------------
157
- 6.64 0.01 6.63 500/500 Array#select
158
- 75.76% 0.17% 6.64 0.01 6.63 500 Object#is_prime
159
- 0.00 0.00 0.00 500/501 Fixnum#-
160
- 6.63 4.06 2.56 500/501 Integer#upto
161
- --------------------------------------------------------------------------------
162
- 2.09 0.00 2.09 1/1 Object#run_primes
163
- 23.89% 0.00% 2.09 0.00 2.09 1 Object#find_largest
164
- 0.00 0.00 0.00 1/501 Fixnum#-
165
- 2.09 0.00 2.09 1/501 Integer#upto
166
- 0.00 0.00 0.00 1/1 Array#first
167
- 0.00 0.00 0.00 1/1 Array#length
168
- --------------------------------------------------------------------------------
169
- 2.09 2.09 0.00 61/61 Integer#upto
170
- 23.89% 23.89% 2.09 2.09 0.00 61 Kernel.sleep
171
- --------------------------------------------------------------------------------
172
- 1.33 1.33 0.00 250862/250862 Integer#upto
173
- 15.12% 15.12% 1.33 1.33 0.00 250862 Fixnum#%
174
- --------------------------------------------------------------------------------
175
- 1.24 1.24 0.00 250862/250862 Integer#upto
176
- 14.13% 14.13% 1.24 1.24 0.00 250862 Fixnum#==
177
- --------------------------------------------------------------------------------
178
- 0.02 0.00 0.02 1/1 Object#run_primes
179
- 0.18% 0.00% 0.02 0.00 0.02 1 Object#make_random_array
180
- 0.02 0.02 0.00 1/1 Array#each_index
181
- 0.00 0.00 0.00 1/1 Class#new
182
- --------------------------------------------------------------------------------
183
- 0.02 0.02 0.00 1/1 Object#make_random_array
184
- 0.18% 0.18% 0.02 0.02 0.00 1 Array#each_index
185
- 0.00 0.00 0.00 500/500 Kernel.rand
186
- 0.00 0.00 0.00 500/500 Array#[]=
187
- --------------------------------------------------------------------------------
188
- 0.00 0.00 0.00 500/501 Object#is_prime
189
- 0.00 0.00 0.00 1/501 Object#find_largest
190
- 0.00% 0.00% 0.00 0.00 0.00 501 Fixnum#-
191
- --------------------------------------------------------------------------------
192
- 0.00 0.00 0.00 1/1 Kernel.rand
193
- 0.00% 0.00% 0.00 0.00 0.00 1 Integer#to_int
194
- --------------------------------------------------------------------------------
195
- 0.00 0.00 0.00 1/1 Object#find_largest
196
- 0.00% 0.00% 0.00 0.00 0.00 1 Array#first
197
- --------------------------------------------------------------------------------
198
- 0.00 0.00 0.00 1/1 Class#new
199
- 0.00% 0.00% 0.00 0.00 0.00 1 Array#initialize
200
- --------------------------------------------------------------------------------
201
- 0.00 0.00 0.00 1/1 Object#find_largest
202
- 0.00% 0.00% 0.00 0.00 0.00 1 Array#length
203
- --------------------------------------------------------------------------------
204
- 0.00 0.00 0.00 1/1 Object#make_random_array
205
- 0.00% 0.00% 0.00 0.00 0.00 1 Class#new
206
- 0.00 0.00 0.00 1/1 Array#initialize
207
- --------------------------------------------------------------------------------
208
- 0.00 0.00 0.00 61/61 Integer#upto
209
- 0.00% 0.00% 0.00 0.00 0.00 61 Fixnum#&gt;
210
- --------------------------------------------------------------------------------
211
- 0.00 0.00 0.00 61/61 Integer#upto
212
- 0.00% 0.00% 0.00 0.00 0.00 61 Array#[]
213
- --------------------------------------------------------------------------------
214
- 0.00 0.00 0.00 500/500 Array#each_index
215
- 0.00% 0.00% 0.00 0.00 0.00 500 Array#[]=
216
- --------------------------------------------------------------------------------
217
- 0.00 0.00 0.00 500/500 Array#each_index
218
- 0.00% 0.00% 0.00 0.00 0.00 500 Kernel.rand
219
- 0.00 0.00 0.00 1/1 Integer#to_int</pre>
220
-
221
- <h2 id="label-Overview">Overview</h2>
222
-
223
- <p>Dashed lines divide the report into entries, with one entry per method.
224
- Entries are sorted by total time which is the time spent in the method
225
- plus its children.</p>
226
-
227
- <p>Each entry has a primary line demarked by values in the %total and %self
228
- columns. The primary line represents the method being profiled. Lines
229
- above it are the methods that called this method (parents) while the lines
230
- below it are the methods it called (children).</p>
231
-
232
- <p>All values are in seconds. For the primary line, the columns represent:</p>
233
-
234
- <pre>%total - The percentage of time spent in this method and its children
235
- %self - The percentage of time spent in this method
236
- total - The time spent in this method and its children.
237
- self - The time spent in this method.
238
- children - The time spent in this method&#39;s children.
239
- calls - The number of times this method was called.
240
- name - The name of the method.</pre>
241
-
242
- <p>The interpretation of method names is:</p>
243
- <ul><li>
244
- <p>toplevel - The root method that calls all other methods</p>
245
- </li><li>
246
- <p>MyObject#test - An instance method “test” of the class “MyObject”</p>
247
- </li><li>
248
- <p>&lt;Object:MyObject&gt;test - The &lt;&gt; characters indicate a singleton
249
- method on a singleton class.</p>
250
- </li></ul>
251
-
252
- <p>For example, we see that 99.48% of the time was spent in Integer#upto and
253
- its children. Of that time, 4.06 seconds was spent in Integer#upto itself
254
- and 4.66 in its children. Overall, Integer#upto was called 501 times.</p>
255
-
256
- <h2 id="label-Parents">Parents</h2>
257
-
258
- <p>In each entry, the lines above the primary line are the methods that
259
- called the current method. If the current method is a root method then no
260
- parents are shown.</p>
261
-
262
- <p>For parent lines, the columns represent:</p>
263
-
264
- <pre>total - The time spent in the current method and it children on behalf of the parent method.
265
- self - The time spent in this method on behalf of the parent method.
266
- children - The time spent in this method&#39;s children on behalf of the parent.
267
- calls - The number of times the parent method called this child</pre>
268
-
269
- <p>Looking at Integer#upto again, we see that it was called 500 times from
270
- Object#is_prime and 1 time from find_largest. Of the 8.72 total seconds
271
- spent in Integer#upto, 6.63 were done for Object#is_prime and 2.09 for
272
- Object#find_largest.</p>
273
-
274
- <h2 id="label-Children">Children</h2>
275
-
276
- <p>In each entry, the lines below the primary line are the methods that the
277
- current method called. If the current method is a leaf method then no
278
- children are shown.</p>
279
-
280
- <p>For children lines, the columns represent:</p>
281
-
282
- <pre>total - The time spent in the child, and its children, on behalf of the current method
283
- self - The time spent in the child on behalf of the current method.
284
- children - The time spent in the child&#39;s children (ie, granchildren) in behalf of the current method
285
- calls - The number of times the child method was called by the current method.</pre>
286
-
287
- <p>Taking our example of Integer#upto, we see that it called five other
288
- methods - Array#[], Fixnum#&gt;, Kernel.sleep, Fixnum#= and Fixnum#%.
289
- Looking at Kernel.sleep, we see that its spent 2.09 seconds working for
290
- Integer#upto and its children spent 0 time working for Integer#upto. To
291
- see the overall time Kernel.sleep took we would have to look up its entry
292
- in the graph table.</p>
293
-
294
- <p></p>
295
-
296
- </div>
297
-
298
-
299
-
300
- <footer id="validator-badges">
301
- <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
302
- <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
303
- <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
304
- </footer>
305
-
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
Binary file
Binary file
Binary file
@@ -1,647 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
6
-
7
- <title>ruby-prof</title>
8
-
9
- <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
10
-
11
- <script type="text/javascript">
12
- var rdoc_rel_prefix = "./";
13
- </script>
14
-
15
- <script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
16
- <script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
17
- <script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
18
- <script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
19
- <script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
20
- <script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
21
-
22
-
23
- <body>
24
- <nav id="metadata">
25
- <nav id="home-section" class="section">
26
- <h3 class="section-header">
27
- <a href="./index.html">Home</a>
28
- <a href="./table_of_contents.html#classes">Classes</a>
29
- <a href="./table_of_contents.html#methods">Methods</a>
30
- </h3>
31
- </nav>
32
-
33
-
34
- <nav id="search-section" class="section project-section" class="initially-hidden">
35
- <form action="#" method="get" accept-charset="utf-8">
36
- <h3 class="section-header">
37
- <input type="text" name="search" placeholder="Search" id="search-field"
38
- title="Type to search, Up and Down to navigate, Enter to load">
39
- </h3>
40
- </form>
41
-
42
- <ul id="search-results" class="initially-hidden"></ul>
43
- </nav>
44
-
45
-
46
- <div id="project-metadata">
47
- <nav id="fileindex-section" class="section project-section">
48
- <h3 class="section-header">Pages</h3>
49
-
50
- <ul>
51
-
52
- <li class="file"><a href="./LICENSE.html">LICENSE</a>
53
-
54
- <li class="file"><a href="./README_rdoc.html">README</a>
55
-
56
- <li class="file"><a href="./examples/flat_txt.html">flat</a>
57
-
58
- <li class="file"><a href="./examples/graph_txt.html">graph</a>
59
-
60
- </ul>
61
- </nav>
62
-
63
- <nav id="classindex-section" class="section project-section">
64
- <h3 class="section-header">Class and Module Index</h3>
65
-
66
- <ul class="link-list">
67
-
68
- <li><a href="./RubyProf.html">RubyProf</a>
69
-
70
- <li><a href="./RubyProf/AbstractPrinter.html">RubyProf::AbstractPrinter</a>
71
-
72
- <li><a href="./RubyProf/AggregateCallInfo.html">RubyProf::AggregateCallInfo</a>
73
-
74
- <li><a href="./RubyProf/CallInfo.html">RubyProf::CallInfo</a>
75
-
76
- <li><a href="./RubyProf/CallInfoPrinter.html">RubyProf::CallInfoPrinter</a>
77
-
78
- <li><a href="./RubyProf/CallInfoVisitor.html">RubyProf::CallInfoVisitor</a>
79
-
80
- <li><a href="./RubyProf/CallStackPrinter.html">RubyProf::CallStackPrinter</a>
81
-
82
- <li><a href="./RubyProf/CallTreePrinter.html">RubyProf::CallTreePrinter</a>
83
-
84
- <li><a href="./RubyProf/Cmd.html">RubyProf::Cmd</a>
85
-
86
- <li><a href="./RubyProf/DotPrinter.html">RubyProf::DotPrinter</a>
87
-
88
- <li><a href="./RubyProf/FlatPrinter.html">RubyProf::FlatPrinter</a>
89
-
90
- <li><a href="./RubyProf/FlatPrinterWithLineNumbers.html">RubyProf::FlatPrinterWithLineNumbers</a>
91
-
92
- <li><a href="./RubyProf/GraphHtmlPrinter.html">RubyProf::GraphHtmlPrinter</a>
93
-
94
- <li><a href="./RubyProf/GraphPrinter.html">RubyProf::GraphPrinter</a>
95
-
96
- <li><a href="./RubyProf/MethodInfo.html">RubyProf::MethodInfo</a>
97
-
98
- <li><a href="./RubyProf/MultiPrinter.html">RubyProf::MultiPrinter</a>
99
-
100
- <li><a href="./RubyProf/Profile.html">RubyProf::Profile</a>
101
-
102
- <li><a href="./RubyProf/ProfileTask.html">RubyProf::ProfileTask</a>
103
-
104
- <li><a href="./RubyProf/Test.html">RubyProf::Test</a>
105
-
106
- <li><a href="./RubyProf/Thread.html">RubyProf::Thread</a>
107
-
108
- <li><a href="./Rack.html">Rack</a>
109
-
110
- <li><a href="./Rack/RubyProf.html">Rack::RubyProf</a>
111
-
112
- </ul>
113
- </nav>
114
-
115
- </div>
116
- </nav>
117
-
118
- <div id="documentation" class="description">
119
-
120
- <h1 id="label-ruby-prof">ruby-prof</h1>
121
-
122
- <p><a href="https://travis-ci.org/ruby-prof/ruby-prof"><img
123
- src="https://travis-ci.org/ruby-prof/ruby-prof.png?branch=master"
124
- alt="Build Status" /></a></p>
125
-
126
- <h2 id="label-Overview">Overview</h2>
127
-
128
- <p>ruby-prof is a fast code profiler for Ruby. Its features include:</p>
129
- <ul><li>
130
- <p>Speed - it is a C extension and therefore many times faster than the
131
- standard Ruby profiler.</p>
132
- </li><li>
133
- <p>Modes - Ruby prof can measure a number of different parameters, including
134
- call times, memory usage and object allocations.</p>
135
- </li><li>
136
- <p>Reports - can generate text and cross-referenced html reports</p>
137
- <ul><li>
138
- <p>Flat Profiles - similar to the reports generated by the standard Ruby
139
- profiler</p>
140
- </li><li>
141
- <p>Graph profiles - similar to GProf, these show how long a method runs, which
142
- methods call it and which methods it calls.</p>
143
- </li><li>
144
- <p>Call tree profiles - outputs results in the calltree format suitable for
145
- the KCacheGrind profiling tool.</p>
146
- </li><li>
147
- <p>Many more – see reports section of this <a
148
- href="README_rdoc.html">README</a>.</p>
149
- </li></ul>
150
- </li><li>
151
- <p>Threads - supports profiling multiple threads simultaneously</p>
152
- </li></ul>
153
-
154
- <h2 id="label-Requirements">Requirements</h2>
155
-
156
- <p>ruby-prof requires Ruby 1.8.7 or 1.9.2 and higher.</p>
157
-
158
- <p>If you are running Linux or Unix you&#39;ll need a C compiler so the
159
- extension can be compiled when it is installed.</p>
160
-
161
- <p>If you are running Windows, then you may need to install the Windows
162
- specific RubyGem which includes an already built extension (see Install
163
- section).</p>
164
-
165
- <h2 id="label-Install">Install</h2>
166
-
167
- <p>The easiest way to install ruby-prof is by using Ruby Gems. To install:</p>
168
-
169
- <pre>gem install ruby-prof</pre>
170
-
171
- <p>If you&#39;re on windows then a prebuilt binary gem is available. You may
172
- of course compile it yourself via use of devkit on MinGW.</p>
173
-
174
- <h2 id="label-Usage">Usage</h2>
175
-
176
- <p>There are two ways of running ruby-prof, via the command line or via its
177
- API.</p>
178
-
179
- <h3 id="label-ruby-prof+executable">ruby-prof executable</h3>
180
-
181
- <p>The first is to use ruby-prof to run the Ruby program you want to profile.
182
- For more information refer to the documentation of the ruby-prof command.</p>
183
-
184
- <h3 id="label-ruby-prof+API">ruby-prof API</h3>
185
-
186
- <p>The second way is to use the ruby-prof API to profile particular segments
187
- of code.</p>
188
-
189
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
190
-
191
- <span class="ruby-comment"># Profile the code</span>
192
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
193
- <span class="ruby-operator">...</span>
194
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
195
- <span class="ruby-operator">...</span>
196
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
197
-
198
- <span class="ruby-comment"># Print a flat profile to text</span>
199
- <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>)
200
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>)
201
- </pre>
202
-
203
- <p>Alternatively, you can use a block to tell ruby-prof what to profile:</p>
204
-
205
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
206
-
207
- <span class="ruby-comment"># Profile the code</span>
208
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
209
- <span class="ruby-operator">...</span>
210
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
211
- <span class="ruby-operator">...</span>
212
- <span class="ruby-keyword">end</span>
213
-
214
- <span class="ruby-comment"># Print a graph profile to text</span>
215
- <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>)
216
- <span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, {})
217
- </pre>
218
-
219
- <p>ruby-prof also supports pausing and resuming profiling runs.</p>
220
-
221
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
222
-
223
- <span class="ruby-comment"># Profile the code</span>
224
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
225
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
226
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">pause</span>
227
- [<span class="ruby-identifier">other</span> <span class="ruby-identifier">code</span>]
228
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span>
229
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
230
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
231
- </pre>
232
-
233
- <p>Note that resume will automatically call start if a profiling run has not
234
- yet started. In addition, resume can also take a block:</p>
235
-
236
- <pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;ruby-prof&#39;</span>
237
-
238
- <span class="ruby-comment"># Profile the code</span>
239
- <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span> <span class="ruby-keyword">do</span>
240
- [<span class="ruby-identifier">code</span> <span class="ruby-identifier">to</span> <span class="ruby-identifier">profile</span>]
241
- <span class="ruby-keyword">end</span>
242
-
243
- <span class="ruby-identifier">data</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
244
- </pre>
245
-
246
- <p>With this usage, resume will automatically call pause at the end of the
247
- block.</p>
248
-
249
- <h2 id="label-Method+and+Thread+Elimination">Method and Thread Elimination</h2>
250
-
251
- <p>ruby-prof supports eliminating specific methods and threads from profiling
252
- results. This is useful for reducing connectivity in the call graph, making
253
- it easier to identify the source of performance problems when using a graph
254
- printer.</p>
255
-
256
- <p>For example, consider Integer#times: it&#39;s hardly ever useful to know
257
- how much time is spent in the method itself. We&#39;re much more interested
258
- in how much the passed in block contributes to the time spent in the method
259
- which contains the Integer#times call.</p>
260
-
261
- <p>Methods are eliminated from the collected data by calling
262
- `eliminate_methods!` on the profiling result, before submitting it to a
263
- printer.</p>
264
-
265
- <pre>result = RubyProf.stop
266
- result.eliminate_methods!([/Integer#times/])</pre>
267
-
268
- <p>The argument given to `eliminate_methods!` is either an array of regular
269
- expressions, or the name of a file containing a list of regular expressions
270
- (line separated text).</p>
271
-
272
- <p>After eliminating methods the resulting profile will appear exactly as if
273
- those methods had been inlined at their call sites.</p>
274
-
275
- <p>In a similar manner, threads can be excluded so they are not profiled at
276
- all. To do this, pass an array of threads to exclude to ruby-prof:</p>
277
-
278
- <pre>RubyProf::exclude_threads = [ thread2 ]
279
- RubyProf.start</pre>
280
-
281
- <p>Note that the excluded threads must be specified <strong>before</strong>
282
- profiling.</p>
283
-
284
- <h2 id="label-Benchmarking+full+load+time+including+rubygems+startup+cost+%3D%3D">Benchmarking full load time including rubygems startup cost ==</h2>
285
-
286
- <p>If you want to get a more accurate measurement of what takes all of a
287
- gem&#39;s bin/xxx command to load, you may want to also measure
288
- rubygems&#39; startup penalty. You can do this by calling into
289
- bin/ruby-prof directly, ex:</p>
290
-
291
- <p>$ gem which ruby-prof</p>
292
-
293
- <pre>g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/lib/ruby-prof.rb</pre>
294
-
295
- <p>now run it thus (substitute lib/ruby-prof.rb with bin/ruby-prof):</p>
296
-
297
- <p>$ ruby g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/bin/ruby-prof
298
- g:192binsome_installed_gem_command</p>
299
-
300
- <p>or</p>
301
-
302
- <p>$ ruby g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/bin/ruby-prof
303
- ./some_file_that_does_a_require_rubygems_at_the_beginning.rb</p>
304
-
305
- <h2 id="label-Profiling+Tests">Profiling Tests</h2>
306
-
307
- <p>ruby-prof supports profiling tests cases written using Ruby&#39;s built-in
308
- unit test framework (ie, test derived from Test::Unit::TestCase). To
309
- enable profiling simply add the following line of code to within your test
310
- class:</p>
311
-
312
- <pre>include RubyProf::Test</pre>
313
-
314
- <p>Each test method is profiled separately. ruby-prof will run each test
315
- method once as a warmup and then ten additional times to gather profile
316
- data. Note that the profile data will <strong>not</strong> include the
317
- class&#39;s setup or teardown methods.</p>
318
-
319
- <p>Separate reports are generated for each method and saved, by default, in
320
- the test process&#39;s working directory. To change this, or other
321
- profiling options, modify your test class&#39;s PROFILE_OPTIONS hash table.
322
- To globally change test profiling options, modify
323
- RubyProf::Test::PROFILE_OPTIONS.</p>
324
-
325
- <h2 id="label-Profiling+Rails">Profiling Rails</h2>
326
-
327
- <p>To profile a Rails application it is vital to run it using production like
328
- settings (cache classes, cache view lookups, etc.). Otherwise, Rail&#39;s
329
- dependency loading code will overwhelm any time spent in the application
330
- itself (our tests show that Rails dependency loading causes a roughly 6x
331
- slowdown). The best way to do this is create a new Rails environment,
332
- profile.rb.</p>
333
-
334
- <p>So to profile Rails:</p>
335
- <ol><li>
336
- <p>Create a new profile.rb environment. Make sure to turn on cache_classes
337
- and cache_template_loading. Otherwise your profiling results will be
338
- overwhelemed by the time Rails spends loading required files. You should
339
- likely turn off caching.</p>
340
- </li><li>
341
- <p>Add the ruby-prof to your gemfile:</p>
342
-
343
- <pre>group :profile do
344
- gem &#39;ruby-prof&#39;
345
- end</pre>
346
- </li><li>
347
- <p>Add the ruby prof rack adapter to your middleware stack. One way to do
348
- this is by adding the following code to config.ru:</p>
349
-
350
- <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>
351
- <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>
352
- <span class="ruby-keyword">end</span>
353
- </pre>
354
-
355
- <p>The path is where you want profiling results to be stored. By default the
356
- rack adapter will generate a html call graph report and flat text report.</p>
357
- </li><li>
358
- <p>Now make a request to your running server. New profiling information will
359
- be generated for each request. Note that each request will overwrite the
360
- profiling reports created by the previous request!</p>
361
- </li></ol>
362
-
363
- <h2 id="label-Reports">Reports</h2>
364
-
365
- <p>ruby-prof can generate a number of different reports:</p>
366
- <ul><li>
367
- <p>Flat Reports</p>
368
- </li><li>
369
- <p>Graph Reports</p>
370
- </li><li>
371
- <p>HTML Graph Reports</p>
372
- </li><li>
373
- <p>Call graphs</p>
374
- </li><li>
375
- <p>Call stack reports</p>
376
- </li><li>
377
- <p>More!</p>
378
- </li></ul>
379
-
380
- <p>Flat profiles show the overall time spent in each method. They are a good
381
- of quickly identifying which methods take the most time. An example of a
382
- flat profile and an explanation can be found in <a
383
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/flat.txt">examples/flat.txt</a>.</p>
384
-
385
- <p>There are several varieties of these – run $ ruby-prof –help</p>
386
-
387
- <p>Graph profiles also show the overall time spent in each method. In
388
- addition, they also show which methods call the current method and which
389
- methods its calls. Thus they are good for understanding how methods gets
390
- called and provide insight into the flow of your program. An example text
391
- graph profile is located at <a
392
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.txt">examples/graph.txt</a>.</p>
393
-
394
- <p>HTML Graph profiles are the same as graph profiles, except output is
395
- generated in hyper-linked HTML. Since graph profiles can be quite large,
396
- the embedded links make it much easier to navigate the results. An example
397
- html graph profile is located at <a
398
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.html">examples/graph.html</a>.</p>
399
-
400
- <p>Call graphs output results in the calltree profile format which is used by
401
- KCachegrind. Call graph support was generously donated by Carl Shimer. More
402
- information about the format can be found at the <a
403
- href="http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindCalltreeFormat">KCachegrind</a>
404
- site.</p>
405
-
406
- <p>Call stack reports produce a HTML visualization of the time spent in each
407
- execution path of the profiled code. An example can be found at <a
408
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/call_stack.html">examples/stack.html</a>.</p>
409
-
410
- <p>Another good example: [<a
411
- href="http://twitpic.com/28z94a">twitpic.com/28z94a</a>]</p>
412
-
413
- <p>Finally, there&#39;s a so called MultiPrinter which can generate several
414
- reports in one profiling run. See <a
415
- href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/multi.stack.html">examples/multi.stack.html</a>.</p>
416
-
417
- <p>There is also a graphviz .dot visualiser.</p>
418
-
419
- <h2 id="label-Printers">Printers</h2>
420
-
421
- <p>Reports are created by printers. Supported printers include:</p>
422
- <ul><li>
423
- <p><a href="RubyProf/FlatPrinter.html">RubyProf::FlatPrinter</a> - Creates a
424
- flat report in text format</p>
425
- </li><li>
426
- <p><a
427
- href="RubyProf/FlatPrinterWithLineNumbers.html">RubyProf::FlatPrinterWithLineNumbers</a>
428
- - same as above but more verbose</p>
429
- </li><li>
430
- <p><a href="RubyProf/GraphPrinter.html">RubyProf::GraphPrinter</a> - Creates a
431
- call graph report in text format</p>
432
- </li><li>
433
- <p><a href="RubyProf/GraphHtmlPrinter.html">RubyProf::GraphHtmlPrinter</a> -
434
- Creates a call graph report in HTML (separate files per thread)</p>
435
- </li><li>
436
- <p><a href="RubyProf/DotPrinter.html">RubyProf::DotPrinter</a> - Creates a
437
- call graph report in GraphViz&#39;s DOT format which can be converted to an
438
- image</p>
439
- </li><li>
440
- <p><a href="RubyProf/CallTreePrinter.html">RubyProf::CallTreePrinter</a> -
441
- Creates a call tree report compatible with KCachegrind.</p>
442
- </li><li>
443
- <p><a href="RubyProf/CallStackPrinter.html">RubyProf::CallStackPrinter</a> -
444
- Creates a HTML visualization of the Ruby stack</p>
445
- </li><li>
446
- <p><a href="RubyProf/MultiPrinter.html">RubyProf::MultiPrinter</a> - Uses the
447
- other printers to create several reports in one profiling run</p>
448
- </li><li>
449
- <p>More!</p>
450
- </li></ul>
451
-
452
- <p>To use a printer:</p>
453
-
454
- <pre class="ruby"><span class="ruby-operator">...</span>
455
- <span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
456
- <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>)
457
- <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>)
458
- </pre>
459
-
460
- <p>The first parameter is any writable IO object such as STDOUT or a file. The
461
- second parameter, specifies the minimum percentage a method must take to be
462
- printed. Percentages should be specified as integers in the range 0 to
463
- 100. For more information please see the documentation for the different
464
- printers.</p>
465
-
466
- <p>The other option is :print_file =&gt; true (default false), which adds the
467
- filename to the output (GraphPrinter only).</p>
468
-
469
- <p>The MultiPrinter differs from the other printers in that it requires a
470
- directory path and a basename for the files it produces.</p>
471
-
472
- <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>)
473
- <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>)
474
- </pre>
475
-
476
- <h2 id="label-Measurements">Measurements</h2>
477
-
478
- <p>Depending on the mode and platform, ruby-prof can measure various aspects
479
- of a Ruby program. Supported measurements include:</p>
480
- <ul><li>
481
- <p>process time (RubyProf::PROCESS_TIME)</p>
482
- </li><li>
483
- <p>wall time (RubyProf::WALL_TIME)</p>
484
- </li><li>
485
- <p>cpu time (RubyProf::CPU_TIME)</p>
486
- </li><li>
487
- <p>object allocations (RubyProf::ALLOCATIONS)</p>
488
- </li><li>
489
- <p>memory usage (RubyProf::MEMORY)</p>
490
- </li><li>
491
- <p>garbage collections runs (RubyProf::GC_RUNS)</p>
492
- </li><li>
493
- <p>garbage collection time (RubyProf::GC_TIME)</p>
494
- </li></ul>
495
-
496
- <p>Process time measures the time used by a process between any two moments.
497
- It is unaffected by other processes concurrently running on the system.
498
- Note that Windows does not support measuring process times - therefore,
499
- measurements on Windows defaults to wall time.</p>
500
-
501
- <p>Wall time measures the real-world time elapsed between any two moments. If
502
- there are other processes concurrently running on the system that use
503
- significant CPU or disk time during a profiling run then the reported
504
- results will be too large.</p>
505
-
506
- <p>CPU time uses the CPU clock counter to measure time. The returned values
507
- are dependent on the correctly setting the CPU&#39;s frequency. This mode
508
- is only supported on Pentium or PowerPC platforms (linux only).</p>
509
-
510
- <p>Object allocation reports show how many objects each method in a program
511
- allocates. This support was added by Sylvain Joyeux and requires a patched
512
- Ruby interpreter. For more information and the patch, please see: <a
513
- href="http://rubyforge.org/tracker/index.php?func=detail&aid=11497&group_id=426&atid=1700">rubyforge.org/tracker/index.php?func=detail&aid=11497&group_id=426&atid=1700</a></p>
514
-
515
- <p>Memory usage reports show how much memory each method in a program uses.
516
- This support was added by Alexander Dymo and requires a patched Ruby
517
- interpreter. For more information, see: <a
518
- href="http://rubyforge.org/tracker/index.php?func=detail&aid=17676&group_id=1814&atid=7062">rubyforge.org/tracker/index.php?func=detail&aid=17676&group_id=1814&atid=7062</a></p>
519
-
520
- <p>Garbage collection runs report how many times Ruby&#39;s garbage collector
521
- is invoked during a profiling session. This support was added by Jeremy
522
- Kemper and requires a patched Ruby interpreter. For more information, see:
523
- <a
524
- href="http://rubyforge.org/tracker/index.php?func=detail&aid=17676&group_id=1814&atid=7062">rubyforge.org/tracker/index.php?func=detail&aid=17676&group_id=1814&atid=7062</a></p>
525
-
526
- <p>Garbage collection time reports how much time is spent in Ruby&#39;s
527
- garbage collector during a profiling session. This support was added by
528
- Jeremy Kemper and requires a patched Ruby interpreter. For more
529
- information, see: <a
530
- href="http://rubyforge.org/tracker/index.php?func=detail&aid=17676&group_id=1814&atid=7062">rubyforge.org/tracker/index.php?func=detail&aid=17676&group_id=1814&atid=7062</a></p>
531
-
532
- <p>To set the measurement:</p>
533
- <ul><li>
534
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
535
- RubyProf::PROCESS_TIME</p>
536
- </li><li>
537
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
538
- RubyProf::WALL_TIME</p>
539
- </li><li>
540
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
541
- RubyProf::CPU_TIME</p>
542
- </li><li>
543
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
544
- RubyProf::ALLOCATIONS</p>
545
- </li><li>
546
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
547
- RubyProf::MEMORY</p>
548
- </li><li>
549
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
550
- RubyProf::GC_RUNS</p>
551
- </li><li>
552
- <p><a href="RubyProf.html#method-c-measure_mode">RubyProf.measure_mode</a> =
553
- RubyProf::GC_TIME</p>
554
- </li></ul>
555
-
556
- <p>The default value is RubyProf::PROCESS_TIME.</p>
557
-
558
- <p>You may also specify the measure_mode by using the RUBY_PROF_MEASURE_MODE
559
- environment variable:</p>
560
- <ul><li>
561
- <p>export RUBY_PROF_MEASURE_MODE=process</p>
562
- </li><li>
563
- <p>export RUBY_PROF_MEASURE_MODE=wall</p>
564
- </li><li>
565
- <p>export RUBY_PROF_MEASURE_MODE=cpu</p>
566
- </li><li>
567
- <p>export RUBY_PROF_MEASURE_MODE=allocations</p>
568
- </li><li>
569
- <p>export RUBY_PROF_MEASURE_MODE=memory</p>
570
- </li><li>
571
- <p>export RUBY_PROF_MEASURE_MODE=gc_runs</p>
572
- </li><li>
573
- <p>export RUBY_PROF_MEASURE_MODE=gc_time</p>
574
- </li></ul>
575
-
576
- <p>On Linux, process time is measured using the clock method provided by the C
577
- runtime library. Note that the clock method does not report time spent in
578
- the kernel or child processes and therefore does not measure time spent in
579
- methods such as Kernel.sleep method. If you need to measure these values,
580
- then use wall time. Wall time is measured using the gettimeofday kernel
581
- method.</p>
582
-
583
- <p>On Windows, timings default to wall times. If you set the clock mode to
584
- PROCESS_TIME, then timing are read using the clock method provided by the C
585
- runtime library. Note though, these values are wall times on Windows and
586
- not process times like on Linux. Wall time is measured using the
587
- GetLocalTime API.</p>
588
-
589
- <p>If you use wall time, the results will be affected by other processes
590
- running on your computer, network delays, disk access, etc. As result, for
591
- the best results, try to make sure your computer is only performing your
592
- profiling run and is otherwise quiescent.</p>
593
-
594
- <p>On both platforms, cpu time is measured using the RDTSC assembly function
595
- provided by the Pentium and PowerPC platforms. CPU time is dependent on the
596
- cpu&#39;s frequency. On Linux, ruby-prof attempts to read this value from
597
- “/proc/cpuinfo.” On Windows, you must manually specify the clock
598
- frequency. This can be done using the RUBY_PROF_CPU_FREQUENCY environment
599
- variable:</p>
600
-
601
- <pre>export RUBY_PROF_CPU_FREQUENCY=&lt;value&gt;</pre>
602
-
603
- <p>You can also directly set the cpu frequency by calling:</p>
604
-
605
- <pre>RubyProf.cpu_frequency = &lt;value&gt;</pre>
606
-
607
- <h2 id="label-Multi-threaded+Applications">Multi-threaded Applications</h2>
608
-
609
- <p>Unfortunately, Ruby does not provide an internal api for detecting thread
610
- context switches in 1.8. As a result, the timings ruby-prof reports for
611
- each thread may be slightly inaccurate. In particular, this will happen
612
- for newly spawned threads that go to sleep immediately (their first call).
613
- For instance, if you use Ruby&#39;s timeout library to wait for 2 seconds,
614
- the 2 seconds will be assigned to the foreground thread and not the newly
615
- created background thread. These errors can largely be avoided if the
616
- background thread performs any operation before going to sleep.</p>
617
-
618
- <h2 id="label-Performance">Performance</h2>
619
-
620
- <p>Significant effort has been put into reducing ruby-prof&#39;s overhead as
621
- much as possible. Our tests show that the overhead associated with
622
- profiling code varies considerably with the code being profiled. Most
623
- programs will run approximately twice as slow while highly recursive
624
- programs (like the fibonacci series test) will run three times slower.</p>
625
-
626
- <h2 id="label-License">License</h2>
627
-
628
- <p>See <a href="LICENSE.html">LICENSE</a> for license information.</p>
629
-
630
- <h2 id="label-Development">Development</h2>
631
-
632
- <p>Code is located at <a
633
- href="https://github.com/ruby-prof/ruby-prof">github.com/ruby-prof/ruby-prof</a></p>
634
-
635
- <p>Google group/mailing list: <a
636
- href="http://groups.google.com/group/ruby-optimization">groups.google.com/group/ruby-optimization</a>
637
- or start a github issue.</p>
638
-
639
- </div>
640
-
641
-
642
- <footer id="validator-badges">
643
- <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
644
- <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.1.
645
- <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
646
- </footer>
647
-