ruby-prof 0.15.7 → 0.15.8

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