ruby-prof 0.18.0-x64-mingw32 → 1.1.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +32 -0
  3. data/LICENSE +2 -2
  4. data/README.rdoc +1 -483
  5. data/Rakefile +3 -6
  6. data/bin/ruby-prof +65 -30
  7. data/ext/ruby_prof/extconf.rb +6 -38
  8. data/ext/ruby_prof/rp_allocation.c +279 -0
  9. data/ext/ruby_prof/rp_allocation.h +31 -0
  10. data/ext/ruby_prof/rp_call_info.c +129 -283
  11. data/ext/ruby_prof/rp_call_info.h +16 -34
  12. data/ext/ruby_prof/rp_measure_allocations.c +25 -49
  13. data/ext/ruby_prof/rp_measure_memory.c +21 -56
  14. data/ext/ruby_prof/rp_measure_process_time.c +35 -39
  15. data/ext/ruby_prof/rp_measure_wall_time.c +36 -19
  16. data/ext/ruby_prof/rp_measurement.c +230 -0
  17. data/ext/ruby_prof/rp_measurement.h +50 -0
  18. data/ext/ruby_prof/rp_method.c +389 -389
  19. data/ext/ruby_prof/rp_method.h +34 -39
  20. data/ext/ruby_prof/rp_profile.c +895 -0
  21. data/ext/ruby_prof/rp_profile.h +37 -0
  22. data/ext/ruby_prof/rp_stack.c +103 -80
  23. data/ext/ruby_prof/rp_stack.h +5 -12
  24. data/ext/ruby_prof/rp_thread.c +143 -83
  25. data/ext/ruby_prof/rp_thread.h +15 -6
  26. data/ext/ruby_prof/ruby_prof.c +11 -757
  27. data/ext/ruby_prof/ruby_prof.h +4 -47
  28. data/ext/ruby_prof/vc/ruby_prof.vcxproj +10 -8
  29. data/lib/{2.6.3 → 2.6.5}/ruby_prof.so +0 -0
  30. data/lib/ruby-prof.rb +2 -18
  31. data/lib/ruby-prof/assets/call_stack_printer.html.erb +713 -0
  32. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  33. data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
  34. data/lib/ruby-prof/call_info.rb +35 -93
  35. data/lib/ruby-prof/call_info_visitor.rb +19 -21
  36. data/lib/ruby-prof/compatibility.rb +37 -107
  37. data/lib/ruby-prof/exclude_common_methods.rb +198 -0
  38. data/lib/ruby-prof/measurement.rb +14 -0
  39. data/lib/ruby-prof/method_info.rb +52 -83
  40. data/lib/ruby-prof/printers/abstract_printer.rb +73 -50
  41. data/lib/ruby-prof/printers/call_info_printer.rb +13 -3
  42. data/lib/ruby-prof/printers/call_stack_printer.rb +62 -145
  43. data/lib/ruby-prof/printers/call_tree_printer.rb +20 -12
  44. data/lib/ruby-prof/printers/dot_printer.rb +5 -5
  45. data/lib/ruby-prof/printers/flat_printer.rb +6 -24
  46. data/lib/ruby-prof/printers/graph_html_printer.rb +6 -192
  47. data/lib/ruby-prof/printers/graph_printer.rb +13 -15
  48. data/lib/ruby-prof/printers/multi_printer.rb +66 -23
  49. data/lib/ruby-prof/profile.rb +10 -3
  50. data/lib/ruby-prof/rack.rb +0 -3
  51. data/lib/ruby-prof/thread.rb +12 -12
  52. data/lib/ruby-prof/version.rb +1 -1
  53. data/ruby-prof.gemspec +2 -2
  54. data/test/abstract_printer_test.rb +0 -27
  55. data/test/alias_test.rb +129 -0
  56. data/test/basic_test.rb +41 -40
  57. data/test/call_info_visitor_test.rb +3 -3
  58. data/test/dynamic_method_test.rb +0 -2
  59. data/test/fiber_test.rb +11 -17
  60. data/test/gc_test.rb +96 -0
  61. data/test/line_number_test.rb +120 -39
  62. data/test/marshal_test.rb +119 -0
  63. data/test/measure_allocations.rb +30 -0
  64. data/test/measure_allocations_test.rb +371 -12
  65. data/test/measure_allocations_trace_test.rb +385 -0
  66. data/test/measure_memory_trace_test.rb +756 -0
  67. data/test/measure_process_time_test.rb +821 -33
  68. data/test/measure_times.rb +54 -0
  69. data/test/measure_wall_time_test.rb +349 -145
  70. data/test/multi_printer_test.rb +1 -34
  71. data/test/parser_timings.rb +24 -0
  72. data/test/pause_resume_test.rb +5 -5
  73. data/test/prime.rb +2 -0
  74. data/test/printer_call_stack_test.rb +28 -0
  75. data/test/printer_call_tree_test.rb +31 -0
  76. data/test/printer_flat_test.rb +68 -0
  77. data/test/printer_graph_html_test.rb +60 -0
  78. data/test/printer_graph_test.rb +41 -0
  79. data/test/printers_test.rb +32 -166
  80. data/test/printing_recursive_graph_test.rb +26 -72
  81. data/test/recursive_test.rb +72 -77
  82. data/test/stack_printer_test.rb +2 -15
  83. data/test/start_stop_test.rb +22 -25
  84. data/test/test_helper.rb +5 -248
  85. data/test/thread_test.rb +11 -54
  86. data/test/unique_call_path_test.rb +16 -28
  87. data/test/yarv_test.rb +1 -0
  88. metadata +28 -36
  89. data/examples/flat.txt +0 -50
  90. data/examples/graph.dot +0 -84
  91. data/examples/graph.html +0 -823
  92. data/examples/graph.txt +0 -139
  93. data/examples/multi.flat.txt +0 -23
  94. data/examples/multi.graph.html +0 -760
  95. data/examples/multi.grind.dat +0 -114
  96. data/examples/multi.stack.html +0 -547
  97. data/examples/stack.html +0 -547
  98. data/ext/ruby_prof/rp_measure.c +0 -40
  99. data/ext/ruby_prof/rp_measure.h +0 -45
  100. data/ext/ruby_prof/rp_measure_cpu_time.c +0 -136
  101. data/ext/ruby_prof/rp_measure_gc_runs.c +0 -73
  102. data/ext/ruby_prof/rp_measure_gc_time.c +0 -60
  103. data/lib/ruby-prof/aggregate_call_info.rb +0 -76
  104. data/lib/ruby-prof/assets/call_stack_printer.css.html +0 -117
  105. data/lib/ruby-prof/assets/call_stack_printer.js.html +0 -385
  106. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -83
  107. data/lib/ruby-prof/profile/exclude_common_methods.rb +0 -207
  108. data/lib/ruby-prof/profile/legacy_method_elimination.rb +0 -50
  109. data/test/aggregate_test.rb +0 -136
  110. data/test/block_test.rb +0 -74
  111. data/test/call_info_test.rb +0 -78
  112. data/test/issue137_test.rb +0 -63
  113. data/test/measure_cpu_time_test.rb +0 -212
  114. data/test/measure_gc_runs_test.rb +0 -32
  115. data/test/measure_gc_time_test.rb +0 -36
  116. data/test/measure_memory_test.rb +0 -33
  117. data/test/method_elimination_test.rb +0 -84
  118. data/test/module_test.rb +0 -45
  119. data/test/stack_test.rb +0 -138
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3ca2e9d0e0792996d6246fcb5c2a76f8cb228be29e14db9fa315efef3056dd0
4
- data.tar.gz: 86c19546e12af9509f101281fe1e845e19a7db814d29c0ef5409a2a0a7d46f0d
3
+ metadata.gz: 92a058890ba891a0ccc0d5ef289dd4a5e0067359592ed04f95047a3bf30d0839
4
+ data.tar.gz: 833c854ce3e2790ea696f411f5b3c8fd1fd9827e9eca4ffa0d2e3bb21871dd60
5
5
  SHA512:
6
- metadata.gz: c99558a587d1219b5f8b438580815aeed2ee94441c15cca67e7da9c7cdcfe5a698693be20374763459bb74f458dd524e3f5200af814e40cc859951991f754335
7
- data.tar.gz: aedc25bae9d7d5d352ad923e258ea785604311c71b7c7d5cebd9c9b1b376d68f3230a786b11620888f84e921a0b198eec0e8afeccf87a310e8b1678de719bb43
6
+ metadata.gz: e9c9c5e882ecd371ceb24365d46446e863fbcfaac365dbd84c1aed3ffd24fafe2d7b8e7bc7d09babe07fc8e0d8877fb5c112917b6c1915305cb881dc34f8d49c
7
+ data.tar.gz: 3206613c98c989672a6d329280c3076efb173e4fea0828b09f57ef4698f546aab8ec8cda04e6ef6ccd9d35101f8b2ae5af0a36b04f5c04fca6afa59543e34706
data/CHANGES CHANGED
@@ -1,3 +1,35 @@
1
+ 1.1.0 (2019-12-14)
2
+ =====================
3
+ Changes
4
+
5
+ * Reimplement merge_fibers (Charlie Savage)
6
+ * Fix crash caused by threads being freed when profiles are freed (Charlie Savage)
7
+
8
+ 1.0.0 (2019-07-29)
9
+ =====================
10
+ ruby-prof's development stretches all the way back to 2005. Fourteen years later, it seems time for version 1.0!
11
+ Version 1.0 is a significant update that greatly improves the internals of ruby-prof and adds a number of improvements.
12
+
13
+ Changes (Charlie Savage):
14
+
15
+ * Profiling is significantly faster - 5x in some cases
16
+ * Recursive profiles are finally handled correctly. Yeah!!!
17
+ * Redesigned reports (Chirs Whitefield)
18
+ * New documentation website (https://ruby-prof.github.io)
19
+ * The ability to measure allocations and memory usage using a standard (unpatched) version of ruby
20
+ * The ability to save and reload profiling results for later analysis
21
+ * The ability track object allocations
22
+
23
+ At the same time, it was also time to remove old code and deprecated methods. These changes include (Charlie Savage):
24
+
25
+ * Drop support for old versions of ruby. Currently 2.4 and up are required.
26
+ * Remove support for method elimination (instead use method exclusion).
27
+ * Remove the CPU_TIME measurement mode since it duplicates the PROCESS_TIME mode and required inline assembly code
28
+ * Remove the GC_TIME and GC_RUNS measurement modes since they required patched ruby versions. In modern ruby it is possible to reimplement this functionality, but it does not seem of that much value (shout out if you want it back).
29
+ * Merge the RubyProf::FlatPrinterWithLineNumbers printer into RubyProf::FlatPrinter.
30
+ * Removed support for RUBY_PROF_EDITOR_URI environment variable that specified the link scheme. This features was more confusing then helpful.
31
+
32
+
1
33
  0.18.0 (2019-05-27)
2
34
  =====================
3
35
  Fixes
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
- Copyright (C) 2005 - 2014 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
2
- Copyright (C) 2010 - 2014 Stefan Kaes <skaes@railsepxress.de>
1
+ Copyright (C) 2005 - 2019 Shugo Maeda <shugo@ruby-lang.org>, Charlie Savage <cfis@savagexi.com> and
2
+ Stefan Kaes <skaes@railsepxress.de>
3
3
  All rights reserved.
4
4
 
5
5
  Redistribution and use in source and binary forms, with or without
data/README.rdoc CHANGED
@@ -2,486 +2,4 @@
2
2
 
3
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]
4
4
 
5
- == Overview
6
-
7
- ruby-prof is a fast code profiler for MRI Ruby. Its features include:
8
-
9
- * Speed - it is a C extension and therefore many times faster than the standard Ruby profiler.
10
- * Modes - Ruby prof can measure a number of different parameters, including call times, memory usage and object allocations.
11
- * Reports - can generate text and cross-referenced html reports
12
- - Flat Profiles - similar to the reports generated by the standard Ruby profiler
13
- - Graph profiles - similar to GProf, these show how long a method runs, which methods call it and which methods it calls.
14
- - Call tree profiles - outputs results in the calltree format suitable for the KCacheGrind profiling tool.
15
- - Many more -- see reports section of this \README.
16
- * Threads - supports profiling multiple threads simultaneously
17
-
18
- == Requirements
19
-
20
- ruby-prof requires Ruby 1.9.3 or higher. Please note some ruby
21
- releases have known bugs which cause ruby-prof problems, like
22
- incorrect measurements. We suggest to use the latest minor patch level
23
- release if possible. In particular, on the 2.1 branch of ruby you
24
- should use at least 2.1.7.
25
-
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.
28
-
29
- If you are running Windows, then you may need to install the
30
- Windows specific RubyGem which includes an already built extension (see Install section).
31
-
32
- == Install
33
-
34
- The easiest way to install ruby-prof is by using Ruby Gems. To
35
- install:
36
-
37
- gem install ruby-prof
38
-
39
- If you're on windows then please install the devkit first so that it
40
- can compile.
41
-
42
- == Usage
43
-
44
- There are three major options for running ruby-prof: via the command
45
- line, via its convenience API or via its core API.
46
-
47
- === ruby-prof Executable
48
-
49
- The first is to use ruby-prof to run the Ruby program you want to
50
- profile. For more information refer to the documentation of the
51
- ruby-prof command:
52
-
53
- $ ruby-prof -h
54
-
55
-
56
- === ruby-prof Convenience API
57
-
58
- The second way is to use the ruby-prof convenience API to profile
59
- particular segments of code.
60
-
61
- require 'ruby-prof'
62
-
63
- # profile the code
64
- RubyProf.start
65
- # ... code to profile ...
66
- result = RubyProf.stop
67
-
68
- # print a flat profile to text
69
- printer = RubyProf::FlatPrinter.new(result)
70
- printer.print(STDOUT)
71
-
72
- Alternatively, you can use a block to tell ruby-prof what to profile:
73
-
74
- require 'ruby-prof'
75
-
76
- # profile the code
77
- result = RubyProf.profile do
78
- # ... code to profile ...
79
- end
80
-
81
- # print a graph profile to text
82
- printer = RubyProf::GraphPrinter.new(result)
83
- printer.print(STDOUT, {})
84
-
85
- ruby-prof also supports pausing and resuming profiling runs.
86
-
87
- require 'ruby-prof'
88
-
89
- # profile the code
90
- RubyProf.start
91
- # ... code to profile ...
92
-
93
- RubyProf.pause
94
- # ... other code ...
95
-
96
- RubyProf.resume
97
- # ... code to profile ...
98
- result = RubyProf.stop
99
-
100
- Note that resume will only work if start has been called previously.
101
- In addition, resume can also take a block:
102
-
103
- require 'ruby-prof'
104
-
105
- RubyProf.resume do
106
- # ... code to profile...
107
- end
108
-
109
- result = RubyProf.stop
110
-
111
- With this usage, resume will automatically call pause at the
112
- end of the block.
113
-
114
- === Profiling Selected Threads (Core API)
115
-
116
- The convenience API does not support running multiple profiles in
117
- separate threads concurrently, but the RubyProf::Profile API does. In
118
- fact, the convenience layer uses the Profile API internally. It all
119
- revolves around Profile objects:
120
-
121
- RubyProf::Profile.new::
122
- Create a profile object given an options hash (see below)
123
-
124
- The following options are available when creating Profile instances:
125
-
126
- measure_mode::
127
- One of the defined measure modes
128
-
129
- exclude_threads::
130
- Array of threads which should not be profiled.
131
-
132
- include_threads::
133
- Array of threads which should be profiled. All other threads will
134
- be ignored.
135
-
136
- merge_fibers::
137
- Whether profiling data for a given thread's fibers should all be
138
- subsumed under a single entry. Basically only useful to produce
139
- callgrind profiles.
140
-
141
- RubyProf::Profile#start::
142
- Start profiling
143
-
144
- RubyProf::Profile#pause::
145
- Pause profiling
146
-
147
- RubyProf::Profile#resume::
148
- Resume profiling
149
-
150
- RubyProf::Profile#stop::
151
- Stop profiling and return self
152
-
153
- RubyProf::Profile#profile::
154
- Perform a profile run and return result. Accepts the same arguments
155
- as RubyProf::Profile.new.
156
-
157
-
158
- == Method Elimination (Deprecated)
159
-
160
- ruby-prof supports eliminating specific methods and threads from
161
- profiling results. This is useful for reducing connectivity in the
162
- call graph, making it easier to identify the source of performance
163
- problems when using a graph printer.
164
-
165
- For example, consider <tt>Integer#times</tt>: it's hardly ever useful
166
- to know how much time is spent in the method itself. We're much more
167
- interested in how much the passed in block contributes to the time
168
- spent in the method which contains the <tt>Integer#times</tt> call.
169
-
170
- Methods are eliminated from the collected data by calling
171
- <tt>eliminate_methods!</tt> on the profiling result, before submitting
172
- it to a printer.
173
-
174
- result = RubyProf.stop
175
- result.eliminate_methods!([/Integer#times/])
176
-
177
- The argument given to <tt>eliminate_methods!</tt> is either an array
178
- of regular expressions, or the name of a file containing a list of
179
- regular expressions (line separated text).
180
-
181
- After eliminating methods the resulting profile will appear exactly as if those methods
182
- had been inlined at their call sites.
183
-
184
-
185
- == Method Exclusion
186
-
187
- ruby-prof supports excluding methods from profiling. The effect on
188
- collected metrics are identical to eliminating methods from the
189
- profiling result in a prost process step. The interface is slightly
190
- different though:
191
-
192
- profile = RubyProf::Profile.new(...)
193
- profile.exclude_methods!(Integer, :times, ...)
194
- profile.start
195
-
196
- A convenience method is provided to exclude a large number of methods
197
- which usually clutter up profiles:
198
-
199
- profile.exclude_common_methods!
200
-
201
- However, this is a somewhat opinionated method collection. It's
202
- usually better to view it as an inspiration instead of using it
203
- directly (see https://github.com/ruby-prof/ruby-prof/blob/e087b7d7ca11eecf1717d95a5c5fea1e36ea3136/lib/ruby-prof/profile/exclude_common_methods.rb).
204
-
205
-
206
- == Profiling Rails
207
-
208
- To profile a Rails application it is vital to run it using production like
209
- settings (cache classes, cache view lookups, etc.). Otherwise, Rail's
210
- dependency loading code will overwhelm any time spent in the application
211
- itself (our tests show that Rails dependency loading causes a roughly 6x
212
- slowdown). The best way to do this is create a new Rails environment,
213
- profile.rb.
214
-
215
- So to profile Rails:
216
-
217
- 1. Create a new profile.rb environment. Make sure to turn on
218
- <tt>cache_classes</tt> and
219
- <tt>cache_template_loading</tt>. Otherwise your profiling results
220
- will be overwhelmed by the time Rails spends loading required
221
- files. You should likely turn off caching.
222
-
223
- 2. Add the ruby-prof to your gemfile:
224
-
225
- group :profile do
226
- gem 'ruby-prof'
227
- end
228
-
229
- 3. Add the ruby prof rack adapter to your middleware stack. One way to
230
- do this is by adding the following code to <tt>config.ru</tt>:
231
-
232
- if Rails.env.profile?
233
- use Rack::RubyProf, :path => './tmp/profile'
234
- end
235
-
236
- The path is where you want profiling results to be stored. By default the
237
- rack adapter will generate a html call graph report and flat text report.
238
-
239
- 4. Now make a request to your running server. New profiling
240
- information will be generated for each request. Note that each
241
- request will overwrite the profiling reports created by the
242
- previous request!
243
-
244
- == Reports
245
-
246
- ruby-prof can generate a number of different reports:
247
-
248
- * Flat Reports
249
- * Graph Reports
250
- * HTML Graph Reports
251
- * Call graphs
252
- * Call stack reports
253
- * More!
254
-
255
- Flat profiles show the overall time spent in each method. They
256
- are a good way of quickly identifying which methods take the most time.
257
- An example of a flat profile and an explanation can be found in
258
- {examples/flat.txt}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/flat.txt].
259
-
260
- There are several varieties of these - run <tt>ruby-prof --help</tt>
261
-
262
- Graph profiles also show the overall time spent in each method. In
263
- addition, they also show which methods call the current method and which
264
- methods its calls. Thus they are good for understanding how methods
265
- gets called and provide insight into the flow of your program. An
266
- example text graph profile is located at
267
- {examples/graph.txt}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.txt].
268
-
269
- HTML Graph profiles are the same as graph profiles, except output is
270
- generated in hyper-linked HTML. Since graph profiles can be quite large,
271
- the embedded links make it much easier to navigate the results. An
272
- example html graph profile is located at
273
- {examples/graph.html}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.html].
274
-
275
- Call graphs output results in the calltree profile format which is used
276
- by KCachegrind. Call graph support was generously donated by Carl
277
- Shimer. More information about the format can be found at the
278
- {KCachegrind}[http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindCalltreeFormat]
279
- site.
280
-
281
- Call stack reports produce a HTML visualization of the time spent in
282
- each execution path of the profiled code. An example can be found at
283
- {examples/stack.html}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/stack.html].
284
-
285
- Another good example: http://twitpic.com/28z94a
286
-
287
- Finally, there's a so called MultiPrinter which can generate several
288
- reports in one profiling run. See
289
- {examples/multi.stack.html}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/multi.stack.html].
290
-
291
- There is also a graphviz .dot visualiser.
292
-
293
- == Printers
294
-
295
- Reports are created by printers. Supported printers include:
296
-
297
- RubyProf::FlatPrinter::
298
- Creates a flat report in text format
299
-
300
- RubyProf::FlatPrinterWithLineNumbers::
301
- Same as above but more verbose
302
-
303
- RubyProf::GraphPrinter::
304
- Creates a call graph report in text format
305
-
306
- RubyProf::GraphHtmlPrinter::
307
- Creates a call graph report in HTML (separate files per thread)
308
-
309
- RubyProf::DotPrinter::
310
- Creates a call graph report in GraphViz's DOT format which can be converted to an image
311
-
312
- RubyProf::CallTreePrinter::
313
- Creates a call tree report compatible with KCachegrind
314
-
315
- RubyProf::CallStackPrinter::
316
- Creates a HTML visualization of the Ruby stack
317
-
318
- RubyProf::MultiPrinter::
319
- Uses the other printers to create several reports in one profiling run
320
-
321
- Most printers are used in the following way:
322
-
323
- result = RubyProf.stop
324
- printer = RubyProf::GraphPrinter.new(result)
325
- printer.print(STDOUT, :min_percent => 2)
326
-
327
-
328
- The first parameter is any writable IO object such as <tt>STDOUT</tt>
329
- or a file. The second parameter, specifies the minimum percentage a
330
- method must take to be printed. Percentages should be specified as
331
- integers in the range 0 to 100. For more information please see the
332
- documentation for the different printers.
333
-
334
- The other option is <tt>:print_file => true</tt> (default false),
335
- which adds the filename to the output (GraphPrinter only).
336
-
337
- <tt>MultiPrinter</tt> and <tt>CallTreePrinter</tt>differ from the
338
- other printers in that they require a directory path and a profile
339
- basename for the files they produce:
340
-
341
- printer = RubyProf::MultiPrinter.new(result)
342
- printer.print(:path => ".", :profile => "profile")
343
-
344
- The values given in the example above are the defaults.
345
-
346
- == Measurements
347
-
348
- Depending on the mode and platform, ruby-prof can measure various
349
- aspects of a Ruby program. Supported measurements include:
350
-
351
- RubyProf::WALL_TIME::
352
- Wall time measures the real-world time
353
- elapsed between any two moments. If there are other processes
354
- concurrently running on the system that use significant CPU or disk
355
- time during a profiling run then the reported results will be larger
356
- than expected.
357
-
358
- RubyProf::PROCESS_TIME::
359
- Process time measures the time used by a process between any two moments.
360
- It is unaffected by other processes concurrently running
361
- on the system. Note that Windows does not support measuring process
362
- times.
363
-
364
- RubyProf::CPU_TIME::
365
- CPU time uses the CPU clock counter to measure time. The returned
366
- values are dependent on the correctly setting the CPU's frequency.
367
- This mode is only supported on Pentium or PowerPC platforms (linux only).
368
-
369
- RubyProf::ALLOCATIONS::
370
- Object allocation reports show how many objects each method in
371
- a program allocates. This support was added by Sylvain Joyeux
372
- and requires a patched Ruby interpreter. See below.
373
-
374
-
375
- RubyProf::MEMORY::
376
- Memory usage reports show how much memory each method in a program
377
- uses. This support was added by Alexander Dymo and requires a
378
- patched Ruby interpreter. See below.
379
-
380
- RubyProf::GC_TIME::
381
- Garbage collection time reports how much time is spent in Ruby's
382
- garbage collector during a profiling session. This support was added
383
- by Jeremy Kemper and requires a patched Ruby interpreter. See below.
384
-
385
- RubyProf::GC_RUNS::
386
- Garbage collection runs report how many times Ruby's garbage collector
387
- is invoked during a profiling session. This support was added by
388
- Jeremy Kemper and requires a patched Ruby interpreter. See below.
389
-
390
- == Patching ruby
391
-
392
- All of the patches to Ruby are included in the railsexpress patchsets
393
- for rvm, see https://github.com/skaes/rvm-patchsets. You can also use
394
- these patches manually with other ruby managers (ruby-install,
395
- ruby-build, etc.).
396
-
397
- Note if you rebuild your ruby with patches you must uninstall and
398
- reinstall the ruby-prof gem to take advantage of the new capabilities.
399
-
400
- == Measure modes
401
-
402
- To set the measurement:
403
-
404
- RubyProf.measure_mode = RubyProf::WALL_TIME
405
- RubyProf.measure_mode = RubyProf::PROCESS_TIME
406
- RubyProf.measure_mode = RubyProf::CPU_TIME
407
- RubyProf.measure_mode = RubyProf::ALLOCATIONS
408
- RubyProf.measure_mode = RubyProf::MEMORY
409
- RubyProf.measure_mode = RubyProf::GC_TIME
410
- RubyProf.measure_mode = RubyProf::GC_RUNS
411
-
412
- The default value is <tt>RubyProf::WALL_TIME</tt>.
413
-
414
- You may also specify the measure mode by using the
415
- <tt>RUBY_PROF_MEASURE_MODE</tt> environment variable:
416
-
417
- export RUBY_PROF_MEASURE_MODE=wall
418
- export RUBY_PROF_MEASURE_MODE=process
419
- export RUBY_PROF_MEASURE_MODE=cpu
420
- export RUBY_PROF_MEASURE_MODE=allocations
421
- export RUBY_PROF_MEASURE_MODE=memory
422
- export RUBY_PROF_MEASURE_MODE=gc_time
423
- export RUBY_PROF_MEASURE_MODE=gc_runs
424
-
425
- On Linux, process time is measured using the clock method provided
426
- by the C runtime library. Note that the clock method does not
427
- report time spent in the kernel or child processes and therefore
428
- does not measure time spent in methods such as Kernel.sleep method.
429
- If you need to measure these values, then use wall time. Wall time
430
- is measured using the gettimeofday kernel method.
431
-
432
- If you set the clock mode to <tt>PROCESS_TIME</tt>, then timings are
433
- read using the clock method provided by the C runtime library. Note
434
- though, these values are wall times on Windows and not process times
435
- like on Linux. Wall time is measured using the GetLocalTime API.
436
-
437
- If you use wall time, the results will be affected by other
438
- processes running on your computer, network delays, disk access,
439
- etc. As result, for the best results, try to make sure your
440
- computer is only performing your profiling run and is
441
- otherwise quiescent.
442
-
443
- == Multi-threaded Applications
444
-
445
- Unfortunately, Ruby does not provide an internal API for detecting
446
- thread context switches. As a result, the timings ruby-prof reports
447
- for each thread may be slightly inaccurate. In particular, this will
448
- happen for newly spawned threads that go to sleep immediately (their
449
- first call). For instance, if you use Ruby's timeout library to wait
450
- for 2 seconds, the 2 seconds will be assigned to the foreground thread
451
- and not the newly created background thread. These errors can largely
452
- be avoided if the background thread performs any operation before
453
- going to sleep.
454
-
455
- == Performance
456
-
457
- Significant effort has been put into reducing ruby-prof's overhead
458
- as much as possible. Our tests show that the overhead associated
459
- with profiling code varies considerably with the code being
460
- profiled. Most programs will run approximately twice as slow
461
- while highly recursive programs (like the fibonacci series test)
462
- will run three times slower.
463
-
464
- == Editing links
465
-
466
- Use <tt>RUBY_PROF_EDITOR_URI</tt> environment variable to open source
467
- code files in your favorite text editor. For example,
468
- <tt>RUBY_PROF_EDITOR_URI=atm</tt> will produce links for Atom text
469
- editor.
470
-
471
- == License
472
-
473
- See LICENSE for license information.
474
-
475
- == API Documentation
476
-
477
- The ruby-prof API documentation for the latest released gem version
478
- can be found here: http://www.rubydoc.info/gems/ruby-prof/
479
-
480
- The ruby-prof API documentation for the master branch is available
481
- here: http://www.rubydoc.info/github/ruby-prof/ruby-prof/
482
-
483
- == Development
484
-
485
- Code is located at https://github.com/ruby-prof/ruby-prof
486
-
487
- Google group/mailing list: http://groups.google.com/group/ruby-optimization or open a github issue.
5
+ For an overview of ruby-prof please see https://ruby-prof.github.io