airbnb-ruby-prof 0.0.1

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 (116) hide show
  1. data/CHANGES +483 -0
  2. data/LICENSE +25 -0
  3. data/README.rdoc +426 -0
  4. data/Rakefile +51 -0
  5. data/bin/ruby-prof +279 -0
  6. data/bin/ruby-prof-check-trace +45 -0
  7. data/examples/flat.txt +50 -0
  8. data/examples/graph.dot +84 -0
  9. data/examples/graph.html +823 -0
  10. data/examples/graph.txt +139 -0
  11. data/examples/multi.flat.txt +23 -0
  12. data/examples/multi.graph.html +760 -0
  13. data/examples/multi.grind.dat +114 -0
  14. data/examples/multi.stack.html +547 -0
  15. data/examples/stack.html +547 -0
  16. data/ext/ruby_prof/extconf.rb +67 -0
  17. data/ext/ruby_prof/rp_call_info.c +374 -0
  18. data/ext/ruby_prof/rp_call_info.h +59 -0
  19. data/ext/ruby_prof/rp_fast_call_tree_printer.c +247 -0
  20. data/ext/ruby_prof/rp_fast_call_tree_printer.h +10 -0
  21. data/ext/ruby_prof/rp_measure.c +71 -0
  22. data/ext/ruby_prof/rp_measure.h +56 -0
  23. data/ext/ruby_prof/rp_measure_allocations.c +74 -0
  24. data/ext/ruby_prof/rp_measure_cpu_time.c +134 -0
  25. data/ext/ruby_prof/rp_measure_gc_runs.c +71 -0
  26. data/ext/ruby_prof/rp_measure_gc_time.c +58 -0
  27. data/ext/ruby_prof/rp_measure_memory.c +75 -0
  28. data/ext/ruby_prof/rp_measure_process_time.c +69 -0
  29. data/ext/ruby_prof/rp_measure_wall_time.c +43 -0
  30. data/ext/ruby_prof/rp_method.c +717 -0
  31. data/ext/ruby_prof/rp_method.h +79 -0
  32. data/ext/ruby_prof/rp_stack.c +221 -0
  33. data/ext/ruby_prof/rp_stack.h +81 -0
  34. data/ext/ruby_prof/rp_thread.c +312 -0
  35. data/ext/ruby_prof/rp_thread.h +36 -0
  36. data/ext/ruby_prof/ruby_prof.c +800 -0
  37. data/ext/ruby_prof/ruby_prof.h +64 -0
  38. data/ext/ruby_prof/vc/ruby_prof.sln +32 -0
  39. data/ext/ruby_prof/vc/ruby_prof_18.vcxproj +108 -0
  40. data/ext/ruby_prof/vc/ruby_prof_19.vcxproj +110 -0
  41. data/ext/ruby_prof/vc/ruby_prof_20.vcxproj +110 -0
  42. data/lib/ruby-prof.rb +63 -0
  43. data/lib/ruby-prof/aggregate_call_info.rb +76 -0
  44. data/lib/ruby-prof/assets/call_stack_printer.css.html +117 -0
  45. data/lib/ruby-prof/assets/call_stack_printer.js.html +385 -0
  46. data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
  47. data/lib/ruby-prof/assets/flame_graph_printer.lib.css.html +149 -0
  48. data/lib/ruby-prof/assets/flame_graph_printer.lib.js.html +707 -0
  49. data/lib/ruby-prof/assets/flame_graph_printer.page.js.html +56 -0
  50. data/lib/ruby-prof/assets/flame_graph_printer.tmpl.html.erb +39 -0
  51. data/lib/ruby-prof/call_info.rb +111 -0
  52. data/lib/ruby-prof/call_info_visitor.rb +40 -0
  53. data/lib/ruby-prof/compatibility.rb +186 -0
  54. data/lib/ruby-prof/method_info.rb +109 -0
  55. data/lib/ruby-prof/printers/abstract_printer.rb +85 -0
  56. data/lib/ruby-prof/printers/call_info_printer.rb +41 -0
  57. data/lib/ruby-prof/printers/call_stack_printer.rb +260 -0
  58. data/lib/ruby-prof/printers/call_tree_printer.rb +130 -0
  59. data/lib/ruby-prof/printers/dot_printer.rb +132 -0
  60. data/lib/ruby-prof/printers/fast_call_tree_printer.rb +87 -0
  61. data/lib/ruby-prof/printers/flame_graph_html_printer.rb +59 -0
  62. data/lib/ruby-prof/printers/flame_graph_json_printer.rb +157 -0
  63. data/lib/ruby-prof/printers/flat_printer.rb +70 -0
  64. data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +64 -0
  65. data/lib/ruby-prof/printers/graph_html_printer.rb +244 -0
  66. data/lib/ruby-prof/printers/graph_printer.rb +116 -0
  67. data/lib/ruby-prof/printers/multi_printer.rb +58 -0
  68. data/lib/ruby-prof/profile.rb +22 -0
  69. data/lib/ruby-prof/profile/exclude_common_methods.rb +201 -0
  70. data/lib/ruby-prof/rack.rb +95 -0
  71. data/lib/ruby-prof/task.rb +147 -0
  72. data/lib/ruby-prof/thread.rb +35 -0
  73. data/lib/ruby-prof/version.rb +4 -0
  74. data/lib/ruby-prof/walker.rb +95 -0
  75. data/lib/unprof.rb +10 -0
  76. data/ruby-prof.gemspec +56 -0
  77. data/test/aggregate_test.rb +136 -0
  78. data/test/basic_test.rb +128 -0
  79. data/test/block_test.rb +74 -0
  80. data/test/call_info_test.rb +78 -0
  81. data/test/call_info_visitor_test.rb +31 -0
  82. data/test/duplicate_names_test.rb +32 -0
  83. data/test/dynamic_method_test.rb +55 -0
  84. data/test/enumerable_test.rb +21 -0
  85. data/test/exceptions_test.rb +16 -0
  86. data/test/exclude_methods_test.rb +146 -0
  87. data/test/exclude_threads_test.rb +53 -0
  88. data/test/fiber_test.rb +79 -0
  89. data/test/issue137_test.rb +63 -0
  90. data/test/line_number_test.rb +71 -0
  91. data/test/measure_allocations_test.rb +26 -0
  92. data/test/measure_cpu_time_test.rb +213 -0
  93. data/test/measure_gc_runs_test.rb +32 -0
  94. data/test/measure_gc_time_test.rb +36 -0
  95. data/test/measure_memory_test.rb +33 -0
  96. data/test/measure_process_time_test.rb +63 -0
  97. data/test/measure_wall_time_test.rb +255 -0
  98. data/test/module_test.rb +45 -0
  99. data/test/multi_measure_test.rb +38 -0
  100. data/test/multi_printer_test.rb +83 -0
  101. data/test/no_method_class_test.rb +15 -0
  102. data/test/pause_resume_test.rb +166 -0
  103. data/test/prime.rb +54 -0
  104. data/test/printers_test.rb +255 -0
  105. data/test/printing_recursive_graph_test.rb +127 -0
  106. data/test/rack_test.rb +93 -0
  107. data/test/recursive_test.rb +212 -0
  108. data/test/singleton_test.rb +38 -0
  109. data/test/stack_printer_test.rb +65 -0
  110. data/test/stack_test.rb +138 -0
  111. data/test/start_stop_test.rb +112 -0
  112. data/test/test_helper.rb +264 -0
  113. data/test/thread_test.rb +187 -0
  114. data/test/unique_call_path_test.rb +202 -0
  115. data/test/yarv_test.rb +55 -0
  116. metadata +211 -0
data/LICENSE ADDED
@@ -0,0 +1,25 @@
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>
3
+ All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions
7
+ are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+ 2. Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
19
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25
+ SUCH DAMAGE.
@@ -0,0 +1,426 @@
1
+ = ruby-prof
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]
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
+
54
+ === ruby-prof Convenience API
55
+
56
+ The second way is to use the ruby-prof convenience API to profile
57
+ particular segments of code.
58
+
59
+ require 'ruby-prof'
60
+
61
+ # profile the code
62
+ RubyProf.start
63
+ # ... code to profile ...
64
+ result = RubyProf.stop
65
+
66
+ # print a flat profile to text
67
+ printer = RubyProf::FlatPrinter.new(result)
68
+ printer.print(STDOUT)
69
+
70
+ Alternatively, you can use a block to tell ruby-prof what to profile:
71
+
72
+ require 'ruby-prof'
73
+
74
+ # profile the code
75
+ result = RubyProf.profile do
76
+ # ... code to profile ...
77
+ end
78
+
79
+ # print a graph profile to text
80
+ printer = RubyProf::GraphPrinter.new(result)
81
+ printer.print(STDOUT, {})
82
+
83
+ ruby-prof also supports pausing and resuming profiling runs.
84
+
85
+ require 'ruby-prof'
86
+
87
+ # profile the code
88
+ RubyProf.start
89
+ # ... code to profile ...
90
+
91
+ RubyProf.pause
92
+ # ... other code ...
93
+
94
+ RubyProf.resume
95
+ # ... code to profile ...
96
+ result = RubyProf.stop
97
+
98
+ Note that resume will only work if start has been called previously.
99
+ In addition, resume can also take a block:
100
+
101
+ require 'ruby-prof'
102
+
103
+ RubyProf.resume do
104
+ # ... code to profile...
105
+ end
106
+
107
+ result = RubyProf.stop
108
+
109
+ With this usage, resume will automatically call pause at the
110
+ end of the block.
111
+
112
+ === Profiling Selected Threads (Core API)
113
+
114
+ The convenience API does not support running multiple profiles in
115
+ separate threads concurrently, but the RubyProf::Profile API does. In
116
+ fact, the convenience layer uses the Profile API internally. It all
117
+ revolves around Profile objects:
118
+
119
+ RubyProf::Profile.new::
120
+ Create a profile object given an options hash (see below)
121
+
122
+ The following options are available when creating Profile instances:
123
+
124
+ measure_mode::
125
+ One of the defined measure modes
126
+
127
+ exclude_threads::
128
+ Array of threads which should not be profiled.
129
+
130
+ include_threads::
131
+ Array of threads which should be profiled. All other threads will
132
+ be ignored.
133
+
134
+ merge_fibers::
135
+ Whether profiling data for a given thread's fibers should all be
136
+ subsumed under a single entry. Basically only useful to produce
137
+ callgrind profiles.
138
+
139
+ RubyProf::Profile#start::
140
+ Start profiling
141
+
142
+ RubyProf::Profile#pause::
143
+ Pause profiling
144
+
145
+ RubyProf::Profile#resume::
146
+ Resume profiling
147
+
148
+ RubyProf::Profile#stop::
149
+ Stop profiling and return self
150
+
151
+ RubyProf::Profile#profile::
152
+ Perform a profile run and return result. Accepts the same arguments
153
+ as RubyProf::Profile.new.
154
+
155
+ == Profiling Rails
156
+
157
+ To profile a Rails application it is vital to run it using production like
158
+ settings (cache classes, cache view lookups, etc.). Otherwise, Rail's
159
+ dependency loading code will overwhelm any time spent in the application
160
+ itself (our tests show that Rails dependency loading causes a roughly 6x
161
+ slowdown). The best way to do this is create a new Rails environment,
162
+ profile.rb.
163
+
164
+ So to profile Rails:
165
+
166
+ 1. Create a new profile.rb environment. Make sure to turn on
167
+ <tt>cache_classes</tt> and
168
+ <tt>cache_template_loading</tt>. Otherwise your profiling results
169
+ will be overwhelmed by the time Rails spends loading required
170
+ files. You should likely turn off caching.
171
+
172
+ 2. Add the ruby-prof to your gemfile:
173
+
174
+ group :profile do
175
+ gem 'ruby-prof'
176
+ end
177
+
178
+ 3. Add the ruby prof rack adapter to your middleware stack. One way to
179
+ do this is by adding the following code to <tt>config.ru</tt>:
180
+
181
+ if Rails.env.profile?
182
+ use Rack::RubyProf, :path => '/temp/profile'
183
+ end
184
+
185
+ The path is where you want profiling results to be stored. By default the
186
+ rack adapter will generate a html call graph report and flat text report.
187
+
188
+ 4. Now make a request to your running server. New profiling
189
+ information will be generated for each request. Note that each
190
+ request will overwrite the profiling reports created by the
191
+ previous request!
192
+
193
+ == Reports
194
+
195
+ ruby-prof can generate a number of different reports:
196
+
197
+ * Flat Reports
198
+ * Graph Reports
199
+ * HTML Graph Reports
200
+ * Call graphs
201
+ * Call stack reports
202
+ * More!
203
+
204
+ Flat profiles show the overall time spent in each method. They
205
+ are a good way of quickly identifying which methods take the most time.
206
+ An example of a flat profile and an explanation can be found in
207
+ {examples/flat.txt}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/flat.txt].
208
+
209
+ There are several varieties of these - run <tt>ruby-prof --help</tt>
210
+
211
+ Graph profiles also show the overall time spent in each method. In
212
+ addition, they also show which methods call the current method and which
213
+ methods its calls. Thus they are good for understanding how methods
214
+ gets called and provide insight into the flow of your program. An
215
+ example text graph profile is located at
216
+ {examples/graph.txt}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.txt].
217
+
218
+ HTML Graph profiles are the same as graph profiles, except output is
219
+ generated in hyper-linked HTML. Since graph profiles can be quite large,
220
+ the embedded links make it much easier to navigate the results. An
221
+ example html graph profile is located at
222
+ {examples/graph.html}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.html].
223
+
224
+ Call graphs output results in the calltree profile format which is used
225
+ by KCachegrind. Call graph support was generously donated by Carl
226
+ Shimer. More information about the format can be found at the
227
+ {KCachegrind}[http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindCalltreeFormat]
228
+ site.
229
+
230
+ Call stack reports produce a HTML visualization of the time spent in
231
+ each execution path of the profiled code. An example can be found at
232
+ {examples/stack.html}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/stack.html].
233
+
234
+ Another good example: http://twitpic.com/28z94a
235
+
236
+ Finally, there's a so called MultiPrinter which can generate several
237
+ reports in one profiling run. See
238
+ {examples/multi.stack.html}[http://github.com/ruby-prof/ruby-prof/tree/master/examples/multi.stack.html].
239
+
240
+ There is also a graphviz .dot visualiser.
241
+
242
+ == Printers
243
+
244
+ Reports are created by printers. Supported printers include:
245
+
246
+ RubyProf::FlatPrinter::
247
+ Creates a flat report in text format
248
+
249
+ RubyProf::FlatPrinterWithLineNumbers::
250
+ Same as above but more verbose
251
+
252
+ RubyProf::GraphPrinter::
253
+ Creates a call graph report in text format
254
+
255
+ RubyProf::GraphHtmlPrinter::
256
+ Creates a call graph report in HTML (separate files per thread)
257
+
258
+ RubyProf::DotPrinter::
259
+ Creates a call graph report in GraphViz's DOT format which can be converted to an image
260
+
261
+ RubyProf::CallTreePrinter::
262
+ Creates a call tree report compatible with KCachegrind
263
+
264
+ RubyProf::CallStackPrinter::
265
+ Creates a HTML visualization of the Ruby stack
266
+
267
+ RubyProf::MultiPrinter::
268
+ Uses the other printers to create several reports in one profiling run
269
+
270
+ To use a printer:
271
+
272
+ result = RubyProf.stop
273
+ printer = RubyProf::GraphPrinter.new(result)
274
+ printer.print(STDOUT, :min_percent => 2)
275
+
276
+
277
+ The first parameter is any writable IO object such as <tt>STDOUT</tt>
278
+ or a file. The second parameter, specifies the minimum percentage a
279
+ method must take to be printed. Percentages should be specified as
280
+ integers in the range 0 to 100. For more information please see the
281
+ documentation for the different printers.
282
+
283
+ The other option is <tt>:print_file => true</tt> (default false),
284
+ which adds the filename to the output (GraphPrinter only).
285
+
286
+ <tt>MultiPrinter</tt> differs from the other printers in that it
287
+ requires a directory path and a basename for the files it produces.
288
+
289
+ printer = RubyProf::MultiPrinter.new(result)
290
+ printer.print(:path => ".", :profile => "profile")
291
+
292
+ == Measurements
293
+
294
+ Depending on the mode and platform, ruby-prof can measure various
295
+ aspects of a Ruby program. Supported measurements include:
296
+
297
+ RubyProf::WALL_TIME::
298
+ Wall time measures the real-world time
299
+ elapsed between any two moments. If there are other processes
300
+ concurrently running on the system that use significant CPU or disk
301
+ time during a profiling run then the reported results will be larger
302
+ than expected.
303
+
304
+ RubyProf::PROCESS_TIME::
305
+ Process time measures the time used by a process between any two moments.
306
+ It is unaffected by other processes concurrently running
307
+ on the system. Note that Windows does not support measuring process
308
+ times.
309
+
310
+ RubyProf::CPU_TIME::
311
+ CPU time uses the CPU clock counter to measure time. The returned
312
+ values are dependent on the correctly setting the CPU's frequency.
313
+ This mode is only supported on Pentium or PowerPC platforms (linux only).
314
+
315
+ RubyProf::ALLOCATIONS::
316
+ Object allocation reports show how many objects each method in
317
+ a program allocates. This support was added by Sylvain Joyeux
318
+ and requires a patched Ruby interpreter. See below.
319
+
320
+
321
+ RubyProf::MEMORY::
322
+ Memory usage reports show how much memory each method in a program
323
+ uses. This support was added by Alexander Dymo and requires a
324
+ patched Ruby interpreter. See below.
325
+
326
+ RubyProf::GC_TIME::
327
+ Garbage collection time reports how much time is spent in Ruby's
328
+ garbage collector during a profiling session. This support was added
329
+ by Jeremy Kemper and requires a patched Ruby interpreter. See below.
330
+
331
+ RubyProf::GC_RUNS::
332
+ Garbage collection runs report how many times Ruby's garbage collector
333
+ is invoked during a profiling session. This support was added by
334
+ Jeremy Kemper and requires a patched Ruby interpreter. See below.
335
+
336
+ == Patching ruby
337
+
338
+ All of the patches to Ruby are included in the railsexpress patchsets
339
+ for rvm, see https://github.com/skaes/rvm-patchsets. You can also use
340
+ these patches manually with other ruby managers (ruby-install,
341
+ ruby-build, etc.).
342
+
343
+ Note if you rebuild your ruby with patches you must uninstall and
344
+ reinstall the ruby-prof gem to take advantage of the new capabilities.
345
+
346
+ == Measure modes
347
+
348
+ To set the measurement:
349
+
350
+ RubyProf.measure_mode = RubyProf::WALL_TIME
351
+ RubyProf.measure_mode = RubyProf::PROCESS_TIME
352
+ RubyProf.measure_mode = RubyProf::CPU_TIME
353
+ RubyProf.measure_mode = RubyProf::ALLOCATIONS
354
+ RubyProf.measure_mode = RubyProf::MEMORY
355
+ RubyProf.measure_mode = RubyProf::GC_TIME
356
+ RubyProf.measure_mode = RubyProf::GC_RUNS
357
+
358
+ The default value is <tt>RubyProf::WALL_TIME</tt>.
359
+
360
+ You may also specify the measure mode by using the
361
+ <tt>RUBY_PROF_MEASURE_MODE</tt> environment variable:
362
+
363
+ export RUBY_PROF_MEASURE_MODE=wall
364
+ export RUBY_PROF_MEASURE_MODE=process
365
+ export RUBY_PROF_MEASURE_MODE=cpu
366
+ export RUBY_PROF_MEASURE_MODE=allocations
367
+ export RUBY_PROF_MEASURE_MODE=memory
368
+ export RUBY_PROF_MEASURE_MODE=gc_time
369
+ export RUBY_PROF_MEASURE_MODE=gc_runs
370
+
371
+ On Linux, process time is measured using the clock method provided
372
+ by the C runtime library. Note that the clock method does not
373
+ report time spent in the kernel or child processes and therefore
374
+ does not measure time spent in methods such as Kernel.sleep method.
375
+ If you need to measure these values, then use wall time. Wall time
376
+ is measured using the gettimeofday kernel method.
377
+
378
+ If you set the clock mode to <tt>PROCESS_TIME</tt>, then timings are
379
+ read using the clock method provided by the C runtime library. Note
380
+ though, these values are wall times on Windows and not process times
381
+ like on Linux. Wall time is measured using the GetLocalTime API.
382
+
383
+ If you use wall time, the results will be affected by other
384
+ processes running on your computer, network delays, disk access,
385
+ etc. As result, for the best results, try to make sure your
386
+ computer is only performing your profiling run and is
387
+ otherwise quiescent.
388
+
389
+ == Multi-threaded Applications
390
+
391
+ Unfortunately, Ruby does not provide an internal API for detecting
392
+ thread context switches. As a result, the timings ruby-prof reports
393
+ for each thread may be slightly inaccurate. In particular, this will
394
+ happen for newly spawned threads that go to sleep immediately (their
395
+ first call). For instance, if you use Ruby's timeout library to wait
396
+ for 2 seconds, the 2 seconds will be assigned to the foreground thread
397
+ and not the newly created background thread. These errors can largely
398
+ be avoided if the background thread performs any operation before
399
+ going to sleep.
400
+
401
+ == Performance
402
+
403
+ Significant effort has been put into reducing ruby-prof's overhead
404
+ as much as possible. Our tests show that the overhead associated
405
+ with profiling code varies considerably with the code being
406
+ profiled. Most programs will run approximately twice as slow
407
+ while highly recursive programs (like the fibonacci series test)
408
+ will run three times slower.
409
+
410
+ == License
411
+
412
+ See LICENSE for license information.
413
+
414
+ == API Documentation
415
+
416
+ The ruby-prof API documentation for the latest released gem version
417
+ can be found here: http://www.rubydoc.info/gems/ruby-prof/
418
+
419
+ The ruby-prof API documentation for the master branch is available
420
+ here: http://www.rubydoc.info/github/ruby-prof/ruby-prof/
421
+
422
+ == Development
423
+
424
+ Code is located at https://github.com/ruby-prof/ruby-prof
425
+
426
+ Google group/mailing list: http://groups.google.com/group/ruby-optimization or open a github issue.