ruby-prof 0.15.8 → 0.15.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +5 -0
  3. data/README.rdoc +187 -185
  4. data/doc/LICENSE.html +114 -0
  5. data/doc/README_rdoc.html +544 -0
  6. data/doc/Rack.html +95 -0
  7. data/doc/Rack/RubyProf.html +223 -0
  8. data/doc/RubyProf.html +961 -0
  9. data/doc/RubyProf/AbstractPrinter.html +546 -0
  10. data/doc/RubyProf/AggregateCallInfo.html +551 -0
  11. data/doc/RubyProf/CallInfo.html +639 -0
  12. data/doc/RubyProf/CallInfoPrinter.html +120 -0
  13. data/doc/RubyProf/CallInfoVisitor.html +198 -0
  14. data/doc/RubyProf/CallStackPrinter.html +1121 -0
  15. data/doc/RubyProf/CallTreePrinter.html +359 -0
  16. data/doc/RubyProf/Cmd.html +631 -0
  17. data/doc/RubyProf/DotPrinter.html +257 -0
  18. data/doc/RubyProf/FlatPrinter.html +163 -0
  19. data/doc/RubyProf/FlatPrinterWithLineNumbers.html +208 -0
  20. data/doc/RubyProf/GraphHtmlPrinter.html +552 -0
  21. data/doc/RubyProf/GraphPrinter.html +139 -0
  22. data/doc/RubyProf/MethodInfo.html +745 -0
  23. data/doc/RubyProf/MultiPrinter.html +358 -0
  24. data/doc/RubyProf/Profile.html +713 -0
  25. data/doc/RubyProf/ProfileTask.html +490 -0
  26. data/doc/RubyProf/Thread.html +268 -0
  27. data/doc/created.rid +13 -13
  28. data/doc/examples/flat_txt.html +138 -0
  29. data/doc/examples/graph_html.html +909 -0
  30. data/doc/examples/graph_txt.html +247 -0
  31. data/doc/images/add.png +0 -0
  32. data/doc/images/arrow_up.png +0 -0
  33. data/doc/images/brick.png +0 -0
  34. data/doc/images/brick_link.png +0 -0
  35. data/doc/images/bug.png +0 -0
  36. data/doc/images/bullet_black.png +0 -0
  37. data/doc/images/bullet_toggle_minus.png +0 -0
  38. data/doc/images/bullet_toggle_plus.png +0 -0
  39. data/doc/images/date.png +0 -0
  40. data/doc/images/delete.png +0 -0
  41. data/doc/images/find.png +0 -0
  42. data/doc/images/macFFBgHack.png +0 -0
  43. data/doc/images/package.png +0 -0
  44. data/doc/images/page_green.png +0 -0
  45. data/doc/images/page_white_text.png +0 -0
  46. data/doc/images/page_white_width.png +0 -0
  47. data/doc/images/plugin.png +0 -0
  48. data/doc/images/ruby.png +0 -0
  49. data/doc/images/tag_blue.png +0 -0
  50. data/doc/images/tag_green.png +0 -0
  51. data/doc/images/transparent.png +0 -0
  52. data/doc/images/wrench.png +0 -0
  53. data/doc/images/wrench_orange.png +0 -0
  54. data/doc/images/zoom.png +0 -0
  55. data/doc/index.html +571 -0
  56. data/doc/js/navigation.js.gz +0 -0
  57. data/doc/js/search_index.js +1 -1
  58. data/doc/js/search_index.js.gz +0 -0
  59. data/doc/js/searcher.js.gz +0 -0
  60. data/doc/table_of_contents.html +893 -0
  61. data/examples/flat.txt +50 -55
  62. data/examples/graph.html +823 -823
  63. data/examples/graph.txt +139 -170
  64. data/ext/ruby_prof/extconf.rb +6 -1
  65. data/lib/ruby-prof/aggregate_call_info.rb +17 -11
  66. data/lib/ruby-prof/call_info.rb +2 -17
  67. data/lib/ruby-prof/method_info.rb +6 -22
  68. data/lib/ruby-prof/printers/graph_html_printer.rb +0 -2
  69. data/lib/ruby-prof/printers/graph_printer.rb +4 -6
  70. data/lib/ruby-prof/rack.rb +7 -0
  71. data/lib/ruby-prof/thread.rb +0 -4
  72. data/lib/ruby-prof/version.rb +1 -1
  73. data/ruby-prof.gemspec +1 -1
  74. data/test/basic_test.rb +26 -26
  75. data/test/issue137_test.rb +63 -0
  76. data/test/measure_allocations_test.rb +4 -3
  77. data/test/measure_cpu_time_test.rb +6 -6
  78. data/test/measure_process_time_test.rb +8 -8
  79. data/test/pause_resume_test.rb +9 -9
  80. data/test/printers_test.rb +1 -1
  81. data/test/printing_recursive_graph_test.rb +127 -0
  82. data/test/rack_test.rb +49 -1
  83. data/test/recursive_test.rb +41 -37
  84. data/test/test_helper.rb +93 -0
  85. metadata +59 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37b855253c996f890816f330170e544cc3961679
4
- data.tar.gz: 412f280dd5407c7005da0af110ed87d0f25cd56f
3
+ metadata.gz: 22ff7386396e7f34166a995b4f7a095d172544ef
4
+ data.tar.gz: caef497365c65eb46e411f511c9f19e30d5d9502
5
5
  SHA512:
6
- metadata.gz: 8135b2e9722ba2a3cba8af88efc3618ffad734478570daa84a792f5bb768cac73b27ea1c6a4437b960459c5200fba7d78e28e6bedf85c9a258dfd178e8077762
7
- data.tar.gz: 0dd3165ec04d338686a3acc9454f9b08f2fd3a97b14aaff26cd35ef75a82f50c9ec3fe1973c9cd143c67f50f853294f935b438f08d8786cd55f71497104b2b55
6
+ metadata.gz: 09c37e34272db2c85851224b6ed454919797b3f6d9e9a2059272df0cbe09d4cbb1720b95683228c02966ad97927cf940c1a0c98a64fd77c684315b511915e528
7
+ data.tar.gz: 6b2aede7156ff82f4929b6d58e67febc869f933a8ef76948fbc785510e5bb350f69a9c0dbc523c5a4778a15f8de647efaa3f836d86d15939e37b857ad8c52bee
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 0.16.0 (2015-12-08)
2
+ ======================
3
+ * rack profiler now supports lambdas for generating profile paths (thx to Jean Rougé)
4
+ * fixed a bug when printing graph profiles
5
+
1
6
  0.15.8 (2015-04-24)
2
7
  ======================
3
8
  * added missing assets to gem build
@@ -1,9 +1,10 @@
1
1
  = ruby-prof
2
+
2
3
  {<img src="https://travis-ci.org/ruby-prof/ruby-prof.png?branch=master" alt="Build Status" />}[https://travis-ci.org/ruby-prof/ruby-prof]
3
4
 
4
5
  == Overview
5
6
 
6
- ruby-prof is a fast code profiler for Ruby. Its features include:
7
+ ruby-prof is a fast code profiler for MRI Ruby. Its features include:
7
8
 
8
9
  * Speed - it is a C extension and therefore many times faster than the standard Ruby profiler.
9
10
  * Modes - Ruby prof can measure a number of different parameters, including call times, memory usage and object allocations.
@@ -11,7 +12,7 @@ ruby-prof is a fast code profiler for Ruby. Its features include:
11
12
  - Flat Profiles - similar to the reports generated by the standard Ruby profiler
12
13
  - Graph profiles - similar to GProf, these show how long a method runs, which methods call it and which methods it calls.
13
14
  - Call tree profiles - outputs results in the calltree format suitable for the KCacheGrind profiling tool.
14
- - Many more -- see reports section of this README.
15
+ - Many more -- see reports section of this \README.
15
16
  * Threads - supports profiling multiple threads simultaneously
16
17
 
17
18
  == Requirements
@@ -20,25 +21,28 @@ ruby-prof requires Ruby 1.9.3 or higher. Please note some ruby
20
21
  releases have known bugs which cause ruby-prof problems, like
21
22
  incorrect measurements. We suggest to use the latest minor patch level
22
23
  release if possible. In particular, on the 2.1 branch of ruby you
23
- should use 2.1.5.
24
+ should use 2.1.7.
24
25
 
25
- If you are running Linux or Unix you'll need a C compiler so the extension
26
- can be compiled when it is installed.
26
+ If you are running Linux or Unix you'll need a C compiler so the
27
+ extension can be compiled when it is installed.
27
28
 
28
29
  If you are running Windows, then you may need to install the
29
30
  Windows specific RubyGem which includes an already built extension (see Install section).
30
31
 
31
32
  == Install
32
33
 
33
- The easiest way to install ruby-prof is by using Ruby Gems. To install:
34
+ The easiest way to install ruby-prof is by using Ruby Gems. To
35
+ install:
34
36
 
35
- gem install ruby-prof
37
+ gem install ruby-prof
36
38
 
37
- If you're on windows then please install the devkit first so that it can compile.
39
+ If you're on windows then please install the devkit first so that it
40
+ can compile.
38
41
 
39
42
  == Usage
40
43
 
41
- There are two ways of running ruby-prof, via the command line or via its API.
44
+ There are two ways of running ruby-prof, via the command line or via
45
+ its API.
42
46
 
43
47
  === ruby-prof executable
44
48
 
@@ -49,62 +53,58 @@ ruby-prof command.
49
53
 
50
54
  === ruby-prof API
51
55
 
52
- The second way is to use the ruby-prof API to profile
53
- particular segments of code.
56
+ The second way is to use the ruby-prof API to profile particular
57
+ segments of code.
54
58
 
55
- require 'ruby-prof'
59
+ require 'ruby-prof'
56
60
 
57
- # Profile the code
58
- RubyProf.start
59
- ...
60
- [code to profile]
61
- ...
62
- result = RubyProf.stop
61
+ # profile the code
62
+ RubyProf.start
63
+ # ... code to profile ...
64
+ result = RubyProf.stop
63
65
 
64
- # Print a flat profile to text
65
- printer = RubyProf::FlatPrinter.new(result)
66
- printer.print(STDOUT)
66
+ # print a flat profile to text
67
+ printer = RubyProf::FlatPrinter.new(result)
68
+ printer.print(STDOUT)
67
69
 
68
- Alternatively, you can use a block to tell ruby-prof what
69
- to profile:
70
+ Alternatively, you can use a block to tell ruby-prof what to profile:
70
71
 
71
- require 'ruby-prof'
72
+ require 'ruby-prof'
72
73
 
73
- # Profile the code
74
- result = RubyProf.profile do
75
- ...
76
- [code to profile]
77
- ...
78
- end
74
+ # profile the code
75
+ result = RubyProf.profile do
76
+ # ... code to profile ...
77
+ end
79
78
 
80
- # Print a graph profile to text
81
- printer = RubyProf::GraphPrinter.new(result)
82
- printer.print(STDOUT, {})
79
+ # print a graph profile to text
80
+ printer = RubyProf::GraphPrinter.new(result)
81
+ printer.print(STDOUT, {})
83
82
 
84
83
  ruby-prof also supports pausing and resuming profiling runs.
85
84
 
86
- require 'ruby-prof'
85
+ require 'ruby-prof'
86
+
87
+ # profile the code
88
+ RubyProf.start
89
+ # ... code to profile ...
90
+
91
+ RubyProf.pause
92
+ # ... other code ...
87
93
 
88
- # Profile the code
89
- RubyProf.start
90
- [code to profile]
91
- RubyProf.pause
92
- [other code]
93
- RubyProf.resume
94
- [code to profile]
95
- result = RubyProf.stop
94
+ RubyProf.resume
95
+ # ... code to profile ...
96
+ result = RubyProf.stop
96
97
 
97
98
  Note that resume will automatically call start if a profiling run
98
99
  has not yet started. In addition, resume can also take a block:
99
100
 
100
- require 'ruby-prof'
101
+ require 'ruby-prof'
101
102
 
102
- # Profile the code
103
- RubyProf.resume do
104
- [code to profile]
105
- end
103
+ RubyProf.resume do
104
+ # ... code to profile...
105
+ end
106
106
 
107
- data = RubyProf.stop
107
+ data = RubyProf.stop
108
108
 
109
109
  With this usage, resume will automatically call pause at the
110
110
  end of the block.
@@ -112,22 +112,26 @@ end of the block.
112
112
 
113
113
  == Method and Thread Elimination
114
114
 
115
- ruby-prof supports eliminating specific methods and threads from profiling
116
- results. This is useful for reducing connectivity in the call graph, making it easier to
117
- identify the source of performance problems when using a graph printer.
115
+ ruby-prof supports eliminating specific methods and threads from
116
+ profiling results. This is useful for reducing connectivity in the
117
+ call graph, making it easier to identify the source of performance
118
+ problems when using a graph printer.
118
119
 
119
- For example, consider Integer#times: it's hardly ever useful to know how much time is
120
- spent in the method itself. We're much more interested in how much the passed in block
121
- contributes to the time spent in the method which contains the Integer#times call.
120
+ For example, consider <tt>Integer#times</tt>: it's hardly ever useful
121
+ to know how much time is spent in the method itself. We're much more
122
+ interested in how much the passed in block contributes to the time
123
+ spent in the method which contains the <tt>Integer#times</tt> call.
122
124
 
123
- Methods are eliminated from the collected data by calling `eliminate_methods!` on the
124
- profiling result, before submitting it to a printer.
125
+ Methods are eliminated from the collected data by calling
126
+ <tt>eliminate_methods!</tt> on the profiling result, before submitting
127
+ it to a printer.
125
128
 
126
- result = RubyProf.stop
127
- result.eliminate_methods!([/Integer#times/])
129
+ result = RubyProf.stop
130
+ result.eliminate_methods!([/Integer#times/])
128
131
 
129
- The argument given to `eliminate_methods!` is either an array of regular expressions, or
130
- the name of a file containing a list of regular expressions (line separated text).
132
+ The argument given to <tt>eliminate_methods!</tt> is either an array
133
+ of regular expressions, or the name of a file containing a list of
134
+ regular expressions (line separated text).
131
135
 
132
136
  After eliminating methods the resulting profile will appear exactly as if those methods
133
137
  had been inlined at their call sites.
@@ -135,30 +139,11 @@ had been inlined at their call sites.
135
139
  In a similar manner, threads can be excluded so they are not profiled at all. To do this,
136
140
  pass an array of threads to exclude to ruby-prof:
137
141
 
138
- RubyProf::exclude_threads = [ thread2 ]
139
- RubyProf.start
142
+ RubyProf::exclude_threads = [ thread2 ]
143
+ RubyProf.start
140
144
 
141
145
  Note that the excluded threads must be specified *before* profiling.
142
146
 
143
-
144
- == Benchmarking full load time including rubygems startup cost
145
-
146
- If you want to get a more accurate measurement of what takes all of a gem's bin/xxx
147
- command to load, you may want to also measure rubygems' startup penalty.
148
- You can do this by calling into bin/ruby-prof directly, ex:
149
-
150
- $ gem which ruby-prof
151
- g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/lib/ruby-prof.rb
152
-
153
- now run it thus (substitute lib/ruby-prof.rb with bin/ruby-prof):
154
-
155
- $ 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
156
-
157
- or
158
-
159
- $ 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
160
-
161
-
162
147
  == Profiling Rails
163
148
 
164
149
  To profile a Rails application it is vital to run it using production like
@@ -170,30 +155,32 @@ profile.rb.
170
155
 
171
156
  So to profile Rails:
172
157
 
173
- 1. Create a new profile.rb environment. Make sure to turn on cache_classes
174
- and cache_template_loading. Otherwise your profiling results will be
175
- overwhelemed by the time Rails spends loading required files. You should
176
- likely turn off caching.
158
+ 1. Create a new profile.rb environment. Make sure to turn on
159
+ <tt>cache_classes</tt> and
160
+ <tt>cache_template_loading</tt>. Otherwise your profiling results
161
+ will be overwhelemed by the time Rails spends loading required
162
+ files. You should likely turn off caching.
177
163
 
178
- 2. Add the ruby-prof to your gemfile:
164
+ 2. Add the ruby-prof to your gemfile:
179
165
 
180
- group :profile do
181
- gem 'ruby-prof'
182
- end
166
+ group :profile do
167
+ gem 'ruby-prof'
168
+ end
183
169
 
184
- 3. Add the ruby prof rack adapter to your middleware stack. One way to
185
- do this is by adding the following code to config.ru:
170
+ 3. Add the ruby prof rack adapter to your middleware stack. One way to
171
+ do this is by adding the following code to <tt>config.ru</tt>:
186
172
 
187
- if Rails.env.profile?
188
- use Rack::RubyProf, :path => '/temp/profile'
189
- end
173
+ if Rails.env.profile?
174
+ use Rack::RubyProf, :path => '/temp/profile'
175
+ end
190
176
 
191
- The path is where you want profiling results to be stored. By default the
192
- rack adapter will generate a html call graph report and flat text report.
177
+ The path is where you want profiling results to be stored. By default the
178
+ rack adapter will generate a html call graph report and flat text report.
193
179
 
194
- 4. Now make a request to your running server. New profiling information will
195
- be generated for each request. Note that each request will overwrite
196
- the profiling reports created by the previous request!
180
+ 4. Now make a request to your running server. New profiling
181
+ information will be generated for each request. Note that each
182
+ request will overwrite the profiling reports created by the
183
+ previous request!
197
184
 
198
185
  == Reports
199
186
 
@@ -211,7 +198,7 @@ are a good way of quickly identifying which methods take the most time.
211
198
  An example of a flat profile and an explanation can be found in
212
199
  {examples/flat.txt}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/flat.txt].
213
200
 
214
- There are several varieties of these -- run $ ruby-prof --help
201
+ There are several varieties of these - run <tt>ruby-prof --help</tt>
215
202
 
216
203
  Graph profiles also show the overall time spent in each method. In
217
204
  addition, they also show which methods call the current method and which
@@ -236,7 +223,7 @@ Call stack reports produce a HTML visualization of the time spent in
236
223
  each execution path of the profiled code. An example can be found at
237
224
  {examples/stack.html}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/stack.html].
238
225
 
239
- Another good example: [http://twitpic.com/28z94a]
226
+ Another good example: http://twitpic.com/28z94a
240
227
 
241
228
  Finally, there's a so called MultiPrinter which can generate several
242
229
  reports in one profiling run. See
@@ -248,106 +235,121 @@ There is also a graphviz .dot visualiser.
248
235
 
249
236
  Reports are created by printers. Supported printers include:
250
237
 
251
- * RubyProf::FlatPrinter - Creates a flat report in text format
252
- * RubyProf::FlatPrinterWithLineNumbers - same as above but more verbose
253
- * RubyProf::GraphPrinter - Creates a call graph report in text format
254
- * RubyProf::GraphHtmlPrinter - Creates a call graph report in HTML (separate files per thread)
255
- * RubyProf::DotPrinter - Creates a call graph report in GraphViz's DOT format which can be converted to an image
256
- * RubyProf::CallTreePrinter - Creates a call tree report compatible with KCachegrind.
257
- * RubyProf::CallStackPrinter - Creates a HTML visualization of the Ruby stack
258
- * RubyProf::MultiPrinter - Uses the other printers to create several reports in one profiling run
259
- * More!
260
-
261
- To use a printer:
262
-
263
- ...
264
- result = RubyProf.stop
265
- printer = RubyProf::GraphPrinter.new(result)
266
- printer.print(STDOUT, :min_percent => 2)
238
+ RubyProf::FlatPrinter::
239
+ Creates a flat report in text format
267
240
 
268
- The first parameter is any writable IO object such as STDOUT or a file.
269
- The second parameter, specifies the minimum percentage a method must take
270
- to be printed. Percentages should be specified as integers in the range 0 to 100.
271
- For more information please see the documentation for the different printers.
241
+ RubyProf::FlatPrinterWithLineNumbers::
242
+ Same as above but more verbose
272
243
 
273
- The other option is :print_file => true (default false), which adds the filename to the
274
- output (GraphPrinter only).
244
+ RubyProf::GraphPrinter::
245
+ Creates a call graph report in text format
275
246
 
276
- The MultiPrinter differs from the other printers in that it requires a directory path
277
- and a basename for the files it produces.
247
+ RubyProf::GraphHtmlPrinter::
248
+ Creates a call graph report in HTML (separate files per thread)
278
249
 
279
- printer = RubyProf::MultiPrinter.new(result)
280
- printer.print(:path => ".", :profile => "profile")
250
+ RubyProf::DotPrinter::
251
+ Creates a call graph report in GraphViz's DOT format which can be converted to an image
281
252
 
253
+ RubyProf::CallTreePrinter::
254
+ Creates a call tree report compatible with KCachegrind
282
255
 
283
- == Measurements
256
+ RubyProf::CallStackPrinter::
257
+ Creates a HTML visualization of the Ruby stack
284
258
 
285
- Depending on the mode and platform, ruby-prof can measure various
286
- aspects of a Ruby program. Supported measurements include:
259
+ RubyProf::MultiPrinter::
260
+ Uses the other printers to create several reports in one profiling run
287
261
 
288
- * wall time (RubyProf::WALL_TIME)
289
- * process time (RubyProf::PROCESS_TIME)
290
- * cpu time (RubyProf::CPU_TIME)
291
- * object allocations (RubyProf::ALLOCATIONS)
292
- * memory usage (RubyProf::MEMORY)
293
- * garbage collection time (RubyProf::GC_TIME)
294
- * garbage collections runs (RubyProf::GC_RUNS)
262
+ To use a printer:
295
263
 
296
- Wall time measures the real-world time elapsed between any two moments.
297
- If there are other processes concurrently running on the system
298
- that use significant CPU or disk time during a profiling run
299
- then the reported results will be larger than expected.
264
+ result = RubyProf.stop
265
+ printer = RubyProf::GraphPrinter.new(result)
266
+ printer.print(STDOUT, :min_percent => 2)
300
267
 
301
- Process time measures the time used by a process between any two moments.
302
- It is unaffected by other processes concurrently running
303
- on the system. Note that Windows does not support measuring process
304
- times.
305
268
 
306
- CPU time uses the CPU clock counter to measure time. The returned
307
- values are dependent on the correctly setting the CPU's frequency.
308
- This mode is only supported on Pentium or PowerPC platforms (linux only).
269
+ The first parameter is any writable IO object such as <tt>STDOUT</tt>
270
+ or a file. The second parameter, specifies the minimum percentage a
271
+ method must take to be printed. Percentages should be specified as
272
+ integers in the range 0 to 100. For more information please see the
273
+ documentation for the different printers.
309
274
 
310
- Object allocation reports show how many objects each method in
311
- a program allocates. This support was added by Sylvain Joyeux
312
- and requires a patched Ruby interpreter. See below.
275
+ The other option is <tt>:print_file => true</tt> (default false),
276
+ which adds the filename to the output (GraphPrinter only).
313
277
 
314
- Memory usage reports show how much memory each method in a program
315
- uses. This support was added by Alexander Dymo and requires a
316
- patched Ruby interpreter. See below.
278
+ <tt>MultiPrinter</tt> differs from the other printers in that it
279
+ requires a directory path and a basename for the files it produces.
317
280
 
318
- Garbage collection time reports how much time is spent in Ruby's
319
- garbage collector during a profiling session. This support was added
320
- by Jeremy Kemper and requires a patched Ruby interpreter. See below.
281
+ printer = RubyProf::MultiPrinter.new(result)
282
+ printer.print(:path => ".", :profile => "profile")
321
283
 
322
- Garbage collection runs report how many times Ruby's garbage collector
323
- is invoked during a profiling session. This support was added by
324
- Jeremy Kemper and requires a patched Ruby interpreter. See below.
284
+ == Measurements
325
285
 
326
- Ruby patches: all of the patches to Ruby are included in the
327
- railsexpress patchsets for rvm, see https://github.com/skaes/rvm-patchsets
286
+ Depending on the mode and platform, ruby-prof can measure various
287
+ aspects of a Ruby program. Supported measurements include:
288
+
289
+ RubyProf::WALL_TIME::
290
+ Wall time measures the real-world time
291
+ elapsed between any two moments. If there are other processes
292
+ concurrently running on the system that use significant CPU or disk
293
+ time during a profiling run then the reported results will be larger
294
+ than expected.
295
+
296
+ RubyProf::PROCESS_TIME::
297
+ Process time measures the time used by a process between any two moments.
298
+ It is unaffected by other processes concurrently running
299
+ on the system. Note that Windows does not support measuring process
300
+ times.
301
+
302
+ RubyProf::CPU_TIME::
303
+ CPU time uses the CPU clock counter to measure time. The returned
304
+ values are dependent on the correctly setting the CPU's frequency.
305
+ This mode is only supported on Pentium or PowerPC platforms (linux only).
306
+
307
+ RubyProf::ALLOCATIONS::
308
+ Object allocation reports show how many objects each method in
309
+ a program allocates. This support was added by Sylvain Joyeux
310
+ and requires a patched Ruby interpreter. See below.
311
+
312
+
313
+ RubyProf::MEMORY::
314
+ Memory usage reports show how much memory each method in a program
315
+ uses. This support was added by Alexander Dymo and requires a
316
+ patched Ruby interpreter. See below.
317
+
318
+ RubyProf::GC_TIME::
319
+ Garbage collection time reports how much time is spent in Ruby's
320
+ garbage collector during a profiling session. This support was added
321
+ by Jeremy Kemper and requires a patched Ruby interpreter. See below.
322
+
323
+ RubyProf::GC_RUNS::
324
+ Garbage collection runs report how many times Ruby's garbage collector
325
+ is invoked during a profiling session. This support was added by
326
+ Jeremy Kemper and requires a patched Ruby interpreter. See below.
327
+
328
+ All of the patches to Ruby are included in the railsexpress patchsets
329
+ for rvm, see https://github.com/skaes/rvm-patchsets
328
330
 
329
331
  To set the measurement:
330
332
 
331
- * RubyProf.measure_mode = RubyProf::WALL_TIME
332
- * RubyProf.measure_mode = RubyProf::PROCESS_TIME
333
- * RubyProf.measure_mode = RubyProf::CPU_TIME
334
- * RubyProf.measure_mode = RubyProf::ALLOCATIONS
335
- * RubyProf.measure_mode = RubyProf::MEMORY
336
- * RubyProf.measure_mode = RubyProf::GC_TIME
337
- * RubyProf.measure_mode = RubyProf::GC_RUNS
333
+ RubyProf.measure_mode = RubyProf::WALL_TIME
334
+ RubyProf.measure_mode = RubyProf::PROCESS_TIME
335
+ RubyProf.measure_mode = RubyProf::CPU_TIME
336
+ RubyProf.measure_mode = RubyProf::ALLOCATIONS
337
+ RubyProf.measure_mode = RubyProf::MEMORY
338
+ RubyProf.measure_mode = RubyProf::GC_TIME
339
+ RubyProf.measure_mode = RubyProf::GC_RUNS
338
340
 
339
- The default value is RubyProf::WALL_TIME.
341
+ The default value is <tt>RubyProf::WALL_TIME</tt>.
340
342
 
341
- You may also specify the measure_mode by using the RUBY_PROF_MEASURE_MODE
342
- environment variable:
343
+ You may also specify the measure mode by using the
344
+ <tt>RUBY_PROF_MEASURE_MODE</tt> environment variable:
343
345
 
344
- * export RUBY_PROF_MEASURE_MODE=wall
345
- * export RUBY_PROF_MEASURE_MODE=process
346
- * export RUBY_PROF_MEASURE_MODE=cpu
347
- * export RUBY_PROF_MEASURE_MODE=allocations
348
- * export RUBY_PROF_MEASURE_MODE=memory
349
- * export RUBY_PROF_MEASURE_MODE=gc_time
350
- * export RUBY_PROF_MEASURE_MODE=gc_runs
346
+ export RUBY_PROF_MEASURE_MODE=wall
347
+ export RUBY_PROF_MEASURE_MODE=process
348
+ export RUBY_PROF_MEASURE_MODE=cpu
349
+ export RUBY_PROF_MEASURE_MODE=allocations
350
+ export RUBY_PROF_MEASURE_MODE=memory
351
+ export RUBY_PROF_MEASURE_MODE=gc_time
352
+ export RUBY_PROF_MEASURE_MODE=gc_runs
351
353
 
352
354
  On Linux, process time is measured using the clock method provided
353
355
  by the C runtime library. Note that the clock method does not
@@ -356,10 +358,10 @@ does not measure time spent in methods such as Kernel.sleep method.
356
358
  If you need to measure these values, then use wall time. Wall time
357
359
  is measured using the gettimeofday kernel method.
358
360
 
359
- If you set the clock mode to PROCESS_TIME, then timings are read using
360
- the clock method provided by the C runtime library. Note though,
361
- these values are wall times on Windows and not process times like on
362
- Linux. Wall time is measured using the GetLocalTime API.
361
+ If you set the clock mode to <tt>PROCESS_TIME</tt>, then timings are
362
+ read using the clock method provided by the C runtime library. Note
363
+ though, these values are wall times on Windows and not process times
364
+ like on Linux. Wall time is measured using the GetLocalTime API.
363
365
 
364
366
  If you use wall time, the results will be affected by other
365
367
  processes running on your computer, network delays, disk access,
@@ -369,7 +371,7 @@ otherwise quiescent.
369
371
 
370
372
  == Multi-threaded Applications
371
373
 
372
- Unfortunately, Ruby does not provide an internal api
374
+ Unfortunately, Ruby does not provide an internal API
373
375
  for detecting thread context switches in 1.8. As a result, the
374
376
  timings ruby-prof reports for each thread may be slightly
375
377
  inaccurate. In particular, this will happen for newly
@@ -397,4 +399,4 @@ See LICENSE for license information.
397
399
 
398
400
  Code is located at https://github.com/ruby-prof/ruby-prof
399
401
 
400
- Google group/mailing list: http://groups.google.com/group/ruby-optimization or start a github issue.
402
+ Google group/mailing list: http://groups.google.com/group/ruby-optimization or open a github issue.