ruby-prof 0.16.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES +532 -467
- data/LICENSE +24 -24
- data/README.rdoc +5 -454
- data/Rakefile +110 -113
- data/bin/ruby-prof +380 -340
- data/bin/ruby-prof-check-trace +45 -45
- data/ext/ruby_prof/extconf.rb +36 -64
- data/ext/ruby_prof/rp_allocation.c +279 -0
- data/ext/ruby_prof/rp_allocation.h +31 -0
- data/ext/ruby_prof/rp_call_info.c +271 -407
- data/ext/ruby_prof/rp_call_info.h +35 -48
- data/ext/ruby_prof/rp_measure_allocations.c +52 -76
- data/ext/ruby_prof/rp_measure_memory.c +42 -77
- data/ext/ruby_prof/rp_measure_process_time.c +67 -71
- data/ext/ruby_prof/rp_measure_wall_time.c +62 -45
- data/ext/ruby_prof/rp_measurement.c +230 -0
- data/ext/ruby_prof/rp_measurement.h +50 -0
- data/ext/ruby_prof/rp_method.c +630 -411
- data/ext/ruby_prof/rp_method.h +70 -52
- data/ext/ruby_prof/rp_profile.c +895 -0
- data/ext/ruby_prof/rp_profile.h +37 -0
- data/ext/ruby_prof/rp_stack.c +196 -128
- data/ext/ruby_prof/rp_stack.h +56 -51
- data/ext/ruby_prof/rp_thread.c +337 -273
- data/ext/ruby_prof/rp_thread.h +36 -27
- data/ext/ruby_prof/ruby_prof.c +48 -671
- data/ext/ruby_prof/ruby_prof.h +17 -56
- data/ext/ruby_prof/vc/ruby_prof.sln +20 -21
- data/ext/ruby_prof/vc/{ruby_prof_20.vcxproj → ruby_prof.vcxproj} +38 -5
- data/lib/ruby-prof.rb +52 -58
- data/lib/ruby-prof/assets/call_stack_printer.html.erb +713 -0
- data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
- data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
- data/lib/ruby-prof/call_info.rb +57 -126
- data/lib/ruby-prof/call_info_visitor.rb +38 -40
- data/lib/ruby-prof/compatibility.rb +109 -178
- data/lib/ruby-prof/exclude_common_methods.rb +198 -0
- data/lib/ruby-prof/measurement.rb +14 -0
- data/lib/ruby-prof/method_info.rb +90 -129
- data/lib/ruby-prof/printers/abstract_printer.rb +127 -85
- data/lib/ruby-prof/printers/call_info_printer.rb +51 -41
- data/lib/ruby-prof/printers/call_stack_printer.rb +182 -260
- data/lib/ruby-prof/printers/call_tree_printer.rb +151 -130
- data/lib/ruby-prof/printers/dot_printer.rb +132 -132
- data/lib/ruby-prof/printers/flat_printer.rb +52 -70
- data/lib/ruby-prof/printers/graph_html_printer.rb +63 -244
- data/lib/ruby-prof/printers/graph_printer.rb +114 -116
- data/lib/ruby-prof/printers/multi_printer.rb +127 -58
- data/lib/ruby-prof/profile.rb +33 -55
- data/lib/ruby-prof/rack.rb +171 -95
- data/lib/ruby-prof/task.rb +147 -147
- data/lib/ruby-prof/thread.rb +35 -41
- data/lib/ruby-prof/version.rb +3 -3
- data/lib/unprof.rb +10 -10
- data/ruby-prof.gemspec +58 -57
- data/test/abstract_printer_test.rb +26 -0
- data/test/alias_test.rb +129 -0
- data/test/basic_test.rb +129 -128
- data/test/call_info_visitor_test.rb +31 -31
- data/test/duplicate_names_test.rb +32 -32
- data/test/dynamic_method_test.rb +53 -55
- data/test/enumerable_test.rb +21 -21
- data/test/exceptions_test.rb +24 -16
- data/test/exclude_methods_test.rb +146 -0
- data/test/exclude_threads_test.rb +53 -53
- data/test/fiber_test.rb +73 -79
- data/test/gc_test.rb +96 -0
- data/test/line_number_test.rb +161 -71
- data/test/marshal_test.rb +119 -0
- data/test/measure_allocations.rb +30 -0
- data/test/measure_allocations_test.rb +385 -26
- data/test/measure_allocations_trace_test.rb +385 -0
- data/test/measure_memory_trace_test.rb +756 -0
- data/test/measure_process_time_test.rb +849 -63
- data/test/measure_times.rb +54 -0
- data/test/measure_wall_time_test.rb +459 -255
- data/test/multi_printer_test.rb +71 -83
- data/test/no_method_class_test.rb +15 -15
- data/test/parser_timings.rb +24 -0
- data/test/pause_resume_test.rb +166 -166
- data/test/prime.rb +56 -54
- data/test/printer_call_stack_test.rb +28 -0
- data/test/printer_call_tree_test.rb +31 -0
- data/test/printer_flat_test.rb +68 -0
- data/test/printer_graph_html_test.rb +60 -0
- data/test/printer_graph_test.rb +41 -0
- data/test/printers_test.rb +141 -255
- data/test/printing_recursive_graph_test.rb +81 -127
- data/test/rack_test.rb +157 -93
- data/test/recursive_test.rb +210 -215
- data/test/singleton_test.rb +38 -38
- data/test/stack_printer_test.rb +64 -78
- data/test/start_stop_test.rb +109 -112
- data/test/test_helper.rb +24 -264
- data/test/thread_test.rb +144 -187
- data/test/unique_call_path_test.rb +190 -202
- data/test/yarv_test.rb +56 -55
- metadata +34 -114
- data/doc/LICENSE.html +0 -114
- data/doc/README_rdoc.html +0 -603
- data/doc/Rack.html +0 -95
- data/doc/Rack/RubyProf.html +0 -226
- data/doc/RubyProf.html +0 -962
- data/doc/RubyProf/AbstractPrinter.html +0 -546
- data/doc/RubyProf/AggregateCallInfo.html +0 -551
- data/doc/RubyProf/CallInfo.html +0 -639
- data/doc/RubyProf/CallInfoPrinter.html +0 -120
- data/doc/RubyProf/CallInfoVisitor.html +0 -198
- data/doc/RubyProf/CallStackPrinter.html +0 -1121
- data/doc/RubyProf/CallTreePrinter.html +0 -641
- data/doc/RubyProf/Cmd.html +0 -631
- data/doc/RubyProf/DotPrinter.html +0 -257
- data/doc/RubyProf/FlatPrinter.html +0 -163
- data/doc/RubyProf/FlatPrinterWithLineNumbers.html +0 -208
- data/doc/RubyProf/GraphHtmlPrinter.html +0 -552
- data/doc/RubyProf/GraphPrinter.html +0 -139
- data/doc/RubyProf/MethodInfo.html +0 -745
- data/doc/RubyProf/MultiPrinter.html +0 -360
- data/doc/RubyProf/Profile.html +0 -763
- data/doc/RubyProf/ProfileTask.html +0 -490
- data/doc/RubyProf/Thread.html +0 -310
- data/doc/created.rid +0 -31
- data/doc/css/fonts.css +0 -167
- data/doc/css/rdoc.css +0 -590
- data/doc/examples/flat_txt.html +0 -138
- data/doc/examples/graph_html.html +0 -909
- data/doc/examples/graph_txt.html +0 -247
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +0 -626
- data/doc/js/darkfish.js +0 -161
- data/doc/js/jquery.js +0 -4
- data/doc/js/navigation.js +0 -142
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search.js +0 -109
- data/doc/js/search_index.js +0 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js +0 -228
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +0 -942
- data/examples/cachegrind.out.1 +0 -114
- data/examples/cachegrind.out.1.32313213 +0 -114
- data/examples/flat.txt +0 -50
- data/examples/graph.dot +0 -84
- data/examples/graph.html +0 -823
- data/examples/graph.txt +0 -139
- data/examples/multi.flat.txt +0 -23
- data/examples/multi.graph.html +0 -760
- data/examples/multi.grind.dat +0 -114
- data/examples/multi.stack.html +0 -547
- data/examples/stack.html +0 -547
- data/ext/ruby_prof/rp_measure.c +0 -40
- data/ext/ruby_prof/rp_measure.h +0 -45
- data/ext/ruby_prof/rp_measure_cpu_time.c +0 -136
- data/ext/ruby_prof/rp_measure_gc_runs.c +0 -73
- data/ext/ruby_prof/rp_measure_gc_time.c +0 -60
- data/ext/ruby_prof/vc/ruby_prof_18.vcxproj +0 -108
- data/ext/ruby_prof/vc/ruby_prof_19.vcxproj +0 -110
- data/lib/ruby-prof/aggregate_call_info.rb +0 -76
- data/lib/ruby-prof/assets/call_stack_printer.css.html +0 -117
- data/lib/ruby-prof/assets/call_stack_printer.js.html +0 -385
- data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -64
- data/test/aggregate_test.rb +0 -136
- data/test/block_test.rb +0 -74
- data/test/call_info_test.rb +0 -78
- data/test/issue137_test.rb +0 -63
- data/test/measure_cpu_time_test.rb +0 -213
- data/test/measure_gc_runs_test.rb +0 -32
- data/test/measure_gc_time_test.rb +0 -36
- data/test/measure_memory_test.rb +0 -33
- data/test/method_elimination_test.rb +0 -84
- data/test/module_test.rb +0 -45
- data/test/stack_test.rb +0 -138
data/doc/README_rdoc.html
DELETED
@@ -1,603 +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+Convenience+API">ruby-prof Convenience API</a>
|
65
|
-
<li><a href="#label-Profiling+Selected+Threads+-28Core+API-29">Profiling Selected Threads (Core API)</a>
|
66
|
-
<li><a href="#label-Method+Elimination">Method Elimination</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-Patching+ruby">Patching ruby</a>
|
72
|
-
<li><a href="#label-Measure+modes">Measure modes</a>
|
73
|
-
<li><a href="#label-Multi-threaded+Applications">Multi-threaded Applications</a>
|
74
|
-
<li><a href="#label-Performance">Performance</a>
|
75
|
-
<li><a href="#label-License">License</a>
|
76
|
-
<li><a href="#label-API+Documentation">API Documentation</a>
|
77
|
-
<li><a href="#label-Development">Development</a>
|
78
|
-
</ul>
|
79
|
-
</div>
|
80
|
-
|
81
|
-
|
82
|
-
<div id="project-metadata">
|
83
|
-
<div id="fileindex-section" class="nav-section">
|
84
|
-
<h3>Pages</h3>
|
85
|
-
|
86
|
-
<ul class="link-list">
|
87
|
-
|
88
|
-
<li><a href="./LICENSE.html">LICENSE</a>
|
89
|
-
|
90
|
-
<li><a href="./README_rdoc.html">README</a>
|
91
|
-
|
92
|
-
<li><a href="./examples/flat_txt.html">flat</a>
|
93
|
-
|
94
|
-
<li><a href="./examples/graph_html.html">graph.html</a>
|
95
|
-
|
96
|
-
<li><a href="./examples/graph_txt.html">graph</a>
|
97
|
-
|
98
|
-
</ul>
|
99
|
-
</div>
|
100
|
-
|
101
|
-
</div>
|
102
|
-
</nav>
|
103
|
-
|
104
|
-
<main role="main" aria-label="Page README.rdoc">
|
105
|
-
|
106
|
-
<h1 id="label-ruby-prof">ruby-prof<span><a href="#label-ruby-prof">¶</a> <a href="#top">↑</a></span></h1>
|
107
|
-
|
108
|
-
<p><a href="https://travis-ci.org/ruby-prof/ruby-prof"><img
|
109
|
-
src="https://travis-ci.org/ruby-prof/ruby-prof.png?branch=master"
|
110
|
-
alt="Build Status" /></a></p>
|
111
|
-
|
112
|
-
<h2 id="label-Overview">Overview<span><a href="#label-Overview">¶</a> <a href="#top">↑</a></span></h2>
|
113
|
-
|
114
|
-
<p>ruby-prof is a fast code profiler for MRI Ruby. Its features include:</p>
|
115
|
-
<ul><li>
|
116
|
-
<p>Speed - it is a C extension and therefore many times faster than the
|
117
|
-
standard Ruby profiler.</p>
|
118
|
-
</li><li>
|
119
|
-
<p>Modes - Ruby prof can measure a number of different parameters, including
|
120
|
-
call times, memory usage and object allocations.</p>
|
121
|
-
</li><li>
|
122
|
-
<p>Reports - can generate text and cross-referenced html reports</p>
|
123
|
-
<ul><li>
|
124
|
-
<p>Flat Profiles - similar to the reports generated by the standard Ruby
|
125
|
-
profiler</p>
|
126
|
-
</li><li>
|
127
|
-
<p>Graph profiles - similar to GProf, these show how long a method runs, which
|
128
|
-
methods call it and which methods it calls.</p>
|
129
|
-
</li><li>
|
130
|
-
<p>Call tree profiles - outputs results in the calltree format suitable for
|
131
|
-
the KCacheGrind profiling tool.</p>
|
132
|
-
</li><li>
|
133
|
-
<p>Many more – see reports section of this README.</p>
|
134
|
-
</li></ul>
|
135
|
-
</li><li>
|
136
|
-
<p>Threads - supports profiling multiple threads simultaneously</p>
|
137
|
-
</li></ul>
|
138
|
-
|
139
|
-
<h2 id="label-Requirements">Requirements<span><a href="#label-Requirements">¶</a> <a href="#top">↑</a></span></h2>
|
140
|
-
|
141
|
-
<p>ruby-prof requires Ruby 1.9.3 or higher. Please note some ruby releases
|
142
|
-
have known bugs which cause ruby-prof problems, like incorrect
|
143
|
-
measurements. We suggest to use the latest minor patch level release if
|
144
|
-
possible. In particular, on the 2.1 branch of ruby you should use at least
|
145
|
-
2.1.7.</p>
|
146
|
-
|
147
|
-
<p>If you are running Linux or Unix you'll need a C compiler so the
|
148
|
-
extension can be compiled when it is installed.</p>
|
149
|
-
|
150
|
-
<p>If you are running Windows, then you may need to install the Windows
|
151
|
-
specific RubyGem which includes an already built extension (see Install
|
152
|
-
section).</p>
|
153
|
-
|
154
|
-
<h2 id="label-Install">Install<span><a href="#label-Install">¶</a> <a href="#top">↑</a></span></h2>
|
155
|
-
|
156
|
-
<p>The easiest way to install ruby-prof is by using Ruby Gems. To install:</p>
|
157
|
-
|
158
|
-
<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>
|
159
|
-
</pre>
|
160
|
-
|
161
|
-
<p>If you're on windows then please install the devkit first so that it
|
162
|
-
can compile.</p>
|
163
|
-
|
164
|
-
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#top">↑</a></span></h2>
|
165
|
-
|
166
|
-
<p>There are three major options for running ruby-prof: via the command line,
|
167
|
-
via its convenience API or via its core API.</p>
|
168
|
-
|
169
|
-
<h3 id="label-ruby-prof+Executable">ruby-prof Executable<span><a href="#label-ruby-prof+Executable">¶</a> <a href="#top">↑</a></span></h3>
|
170
|
-
|
171
|
-
<p>The first is to use ruby-prof to run the Ruby program you want to profile.
|
172
|
-
For more information refer to the documentation of the ruby-prof command.</p>
|
173
|
-
|
174
|
-
<h3 id="label-ruby-prof+Convenience+API">ruby-prof Convenience API<span><a href="#label-ruby-prof+Convenience+API">¶</a> <a href="#top">↑</a></span></h3>
|
175
|
-
|
176
|
-
<p>The second way is to use the ruby-prof convenience API to profile
|
177
|
-
particular segments of code.</p>
|
178
|
-
|
179
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
|
180
|
-
|
181
|
-
<span class="ruby-comment"># profile the code</span>
|
182
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
|
183
|
-
<span class="ruby-comment"># ... code to profile ...</span>
|
184
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
|
185
|
-
|
186
|
-
<span class="ruby-comment"># print a flat profile to text</span>
|
187
|
-
<span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">FlatPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
|
188
|
-
<span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>)
|
189
|
-
</pre>
|
190
|
-
|
191
|
-
<p>Alternatively, you can use a block to tell ruby-prof what to profile:</p>
|
192
|
-
|
193
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
|
194
|
-
|
195
|
-
<span class="ruby-comment"># profile the code</span>
|
196
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
|
197
|
-
<span class="ruby-comment"># ... code to profile ...</span>
|
198
|
-
<span class="ruby-keyword">end</span>
|
199
|
-
|
200
|
-
<span class="ruby-comment"># print a graph profile to text</span>
|
201
|
-
<span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GraphPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
|
202
|
-
<span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, {})
|
203
|
-
</pre>
|
204
|
-
|
205
|
-
<p>ruby-prof also supports pausing and resuming profiling runs.</p>
|
206
|
-
|
207
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
|
208
|
-
|
209
|
-
<span class="ruby-comment"># profile the code</span>
|
210
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">start</span>
|
211
|
-
<span class="ruby-comment"># ... code to profile ...</span>
|
212
|
-
|
213
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">pause</span>
|
214
|
-
<span class="ruby-comment"># ... other code ...</span>
|
215
|
-
|
216
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span>
|
217
|
-
<span class="ruby-comment"># ... code to profile ...</span>
|
218
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
|
219
|
-
</pre>
|
220
|
-
|
221
|
-
<p>Note that resume will only work if start has been called previously. In
|
222
|
-
addition, resume can also take a block:</p>
|
223
|
-
|
224
|
-
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'ruby-prof'</span>
|
225
|
-
|
226
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">resume</span> <span class="ruby-keyword">do</span>
|
227
|
-
<span class="ruby-comment"># ... code to profile...</span>
|
228
|
-
<span class="ruby-keyword">end</span>
|
229
|
-
|
230
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
|
231
|
-
</pre>
|
232
|
-
|
233
|
-
<p>With this usage, resume will automatically call pause at the end of the
|
234
|
-
block.</p>
|
235
|
-
|
236
|
-
<h3 id="label-Profiling+Selected+Threads+-28Core+API-29">Profiling Selected Threads (Core API)<span><a href="#label-Profiling+Selected+Threads+-28Core+API-29">¶</a> <a href="#top">↑</a></span></h3>
|
237
|
-
|
238
|
-
<p>The convenience API does not support running multiple profiles in separate
|
239
|
-
threads concurrently, but the <a
|
240
|
-
href="RubyProf/Profile.html">RubyProf::Profile</a> API does. In fact, the
|
241
|
-
convenience layer uses the Profile API internally. It all revolves around
|
242
|
-
Profile objects:</p>
|
243
|
-
<dl class="rdoc-list note-list"><dt><a href="RubyProf/Profile.html#method-c-new">RubyProf::Profile.new</a>
|
244
|
-
<dd>
|
245
|
-
<p>Create a profile object given an options hash (see below)</p>
|
246
|
-
|
247
|
-
<p>The following options are available when creating Profile instances:</p>
|
248
|
-
<dl class="rdoc-list note-list"><dt>measure_mode
|
249
|
-
<dd>
|
250
|
-
<p>One of the defined measure modes</p>
|
251
|
-
</dd><dt>exclude_threads
|
252
|
-
<dd>
|
253
|
-
<p>Array of threads which should not be profiled.</p>
|
254
|
-
</dd><dt>include_threads
|
255
|
-
<dd>
|
256
|
-
<p>Array of threads which should be profiled. All other threads will be
|
257
|
-
ignored.</p>
|
258
|
-
</dd><dt>merge_fibers
|
259
|
-
<dd>
|
260
|
-
<p>Whether profiling data for a given thread's fibers should all be
|
261
|
-
subsumed under a single entry. Basically only useful to produce callgrind
|
262
|
-
profiles.</p>
|
263
|
-
</dd></dl>
|
264
|
-
</dd><dt><a href="RubyProf/Profile.html#method-i-start">RubyProf::Profile#start</a>
|
265
|
-
<dd>
|
266
|
-
<p>Start profiling</p>
|
267
|
-
</dd><dt><a href="RubyProf/Profile.html#method-i-pause">RubyProf::Profile#pause</a>
|
268
|
-
<dd>
|
269
|
-
<p>Pause profiling</p>
|
270
|
-
</dd><dt><a href="RubyProf/Profile.html#method-i-resume">RubyProf::Profile#resume</a>
|
271
|
-
<dd>
|
272
|
-
<p>Resume profiling</p>
|
273
|
-
</dd><dt><a href="RubyProf/Profile.html#method-i-stop">RubyProf::Profile#stop</a>
|
274
|
-
<dd>
|
275
|
-
<p>Stop profiling and return self</p>
|
276
|
-
</dd><dt>RubyProf::Profile#profile
|
277
|
-
<dd>
|
278
|
-
<p>Perform a profile run and return result. Accepts the same arguments as <a
|
279
|
-
href="RubyProf/Profile.html#method-c-new">RubyProf::Profile.new</a>.</p>
|
280
|
-
</dd></dl>
|
281
|
-
|
282
|
-
<h2 id="label-Method+Elimination">Method Elimination<span><a href="#label-Method+Elimination">¶</a> <a href="#top">↑</a></span></h2>
|
283
|
-
|
284
|
-
<p>ruby-prof supports eliminating specific methods and threads from profiling
|
285
|
-
results. This is useful for reducing connectivity in the call graph, making
|
286
|
-
it easier to identify the source of performance problems when using a graph
|
287
|
-
printer.</p>
|
288
|
-
|
289
|
-
<p>For example, consider <code>Integer#times</code>: it's hardly ever
|
290
|
-
useful to know how much time is spent in the method itself. We're much
|
291
|
-
more interested in how much the passed in block contributes to the time
|
292
|
-
spent in the method which contains the <code>Integer#times</code> call.</p>
|
293
|
-
|
294
|
-
<p>Methods are eliminated from the collected data by calling
|
295
|
-
<code>eliminate_methods!</code> on the profiling result, before submitting
|
296
|
-
it to a printer.</p>
|
297
|
-
|
298
|
-
<pre class="ruby"><span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
|
299
|
-
<span class="ruby-identifier">result</span>.<span class="ruby-identifier">eliminate_methods!</span>([<span class="ruby-node">/Integer#times/</span>])
|
300
|
-
</pre>
|
301
|
-
|
302
|
-
<p>The argument given to <code>eliminate_methods!</code> is either an array of
|
303
|
-
regular expressions, or the name of a file containing a list of regular
|
304
|
-
expressions (line separated text).</p>
|
305
|
-
|
306
|
-
<p>After eliminating methods the resulting profile will appear exactly as if
|
307
|
-
those methods had been inlined at their call sites.</p>
|
308
|
-
|
309
|
-
<h2 id="label-Profiling+Rails">Profiling Rails<span><a href="#label-Profiling+Rails">¶</a> <a href="#top">↑</a></span></h2>
|
310
|
-
|
311
|
-
<p>To profile a Rails application it is vital to run it using production like
|
312
|
-
settings (cache classes, cache view lookups, etc.). Otherwise, Rail's
|
313
|
-
dependency loading code will overwhelm any time spent in the application
|
314
|
-
itself (our tests show that Rails dependency loading causes a roughly 6x
|
315
|
-
slowdown). The best way to do this is create a new Rails environment,
|
316
|
-
profile.rb.</p>
|
317
|
-
|
318
|
-
<p>So to profile Rails:</p>
|
319
|
-
<ol><li>
|
320
|
-
<p>Create a new profile.rb environment. Make sure to turn on
|
321
|
-
<code>cache_classes</code> and <code>cache_template_loading</code>.
|
322
|
-
Otherwise your profiling results will be overwhelmed by the time Rails
|
323
|
-
spends loading required files. You should likely turn off caching.</p>
|
324
|
-
</li><li>
|
325
|
-
<p>Add the ruby-prof to your gemfile:</p>
|
326
|
-
|
327
|
-
<pre class="ruby"><span class="ruby-identifier">group</span> :<span class="ruby-identifier">profile</span> <span class="ruby-keyword">do</span>
|
328
|
-
<span class="ruby-identifier">gem</span> <span class="ruby-string">'ruby-prof'</span>
|
329
|
-
<span class="ruby-keyword">end</span>
|
330
|
-
</pre>
|
331
|
-
</li><li>
|
332
|
-
<p>Add the ruby prof rack adapter to your middleware stack. One way to do
|
333
|
-
this is by adding the following code to <code>config.ru</code>:</p>
|
334
|
-
|
335
|
-
<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>
|
336
|
-
<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">></span> <span class="ruby-string">'/temp/profile'</span>
|
337
|
-
<span class="ruby-keyword">end</span>
|
338
|
-
</pre>
|
339
|
-
|
340
|
-
<p>The path is where you want profiling results to be stored. By default the
|
341
|
-
rack adapter will generate a html call graph report and flat text report.</p>
|
342
|
-
</li><li>
|
343
|
-
<p>Now make a request to your running server. New profiling information will
|
344
|
-
be generated for each request. Note that each request will overwrite the
|
345
|
-
profiling reports created by the previous request!</p>
|
346
|
-
</li></ol>
|
347
|
-
|
348
|
-
<h2 id="label-Reports">Reports<span><a href="#label-Reports">¶</a> <a href="#top">↑</a></span></h2>
|
349
|
-
|
350
|
-
<p>ruby-prof can generate a number of different reports:</p>
|
351
|
-
<ul><li>
|
352
|
-
<p>Flat Reports</p>
|
353
|
-
</li><li>
|
354
|
-
<p>Graph Reports</p>
|
355
|
-
</li><li>
|
356
|
-
<p>HTML Graph Reports</p>
|
357
|
-
</li><li>
|
358
|
-
<p>Call graphs</p>
|
359
|
-
</li><li>
|
360
|
-
<p>Call stack reports</p>
|
361
|
-
</li><li>
|
362
|
-
<p>More!</p>
|
363
|
-
</li></ul>
|
364
|
-
|
365
|
-
<p>Flat profiles show the overall time spent in each method. They are a good
|
366
|
-
way of quickly identifying which methods take the most time. An example of
|
367
|
-
a flat profile and an explanation can be found in <a
|
368
|
-
href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/flat.txt">examples/flat.txt</a>.</p>
|
369
|
-
|
370
|
-
<p>There are several varieties of these - run <code>ruby-prof --help</code></p>
|
371
|
-
|
372
|
-
<p>Graph profiles also show the overall time spent in each method. In
|
373
|
-
addition, they also show which methods call the current method and which
|
374
|
-
methods its calls. Thus they are good for understanding how methods gets
|
375
|
-
called and provide insight into the flow of your program. An example text
|
376
|
-
graph profile is located at <a
|
377
|
-
href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.txt">examples/graph.txt</a>.</p>
|
378
|
-
|
379
|
-
<p>HTML Graph profiles are the same as graph profiles, except output is
|
380
|
-
generated in hyper-linked HTML. Since graph profiles can be quite large,
|
381
|
-
the embedded links make it much easier to navigate the results. An example
|
382
|
-
html graph profile is located at <a
|
383
|
-
href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/graph.html">examples/graph.html</a>.</p>
|
384
|
-
|
385
|
-
<p>Call graphs output results in the calltree profile format which is used by
|
386
|
-
KCachegrind. Call graph support was generously donated by Carl Shimer. More
|
387
|
-
information about the format can be found at the <a
|
388
|
-
href="http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindCalltreeFormat">KCachegrind</a>
|
389
|
-
site.</p>
|
390
|
-
|
391
|
-
<p>Call stack reports produce a HTML visualization of the time spent in each
|
392
|
-
execution path of the profiled code. An example can be found at <a
|
393
|
-
href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/stack.html">examples/stack.html</a>.</p>
|
394
|
-
|
395
|
-
<p>Another good example: <a
|
396
|
-
href="http://twitpic.com/28z94a">twitpic.com/28z94a</a></p>
|
397
|
-
|
398
|
-
<p>Finally, there's a so called MultiPrinter which can generate several
|
399
|
-
reports in one profiling run. See <a
|
400
|
-
href="http://github.com/ruby-prof/ruby-prof/tree/master/examples/multi.stack.html">examples/multi.stack.html</a>.</p>
|
401
|
-
|
402
|
-
<p>There is also a graphviz .dot visualiser.</p>
|
403
|
-
|
404
|
-
<h2 id="label-Printers">Printers<span><a href="#label-Printers">¶</a> <a href="#top">↑</a></span></h2>
|
405
|
-
|
406
|
-
<p>Reports are created by printers. Supported printers include:</p>
|
407
|
-
<dl class="rdoc-list note-list"><dt><a href="RubyProf/FlatPrinter.html">RubyProf::FlatPrinter</a>
|
408
|
-
<dd>
|
409
|
-
<p>Creates a flat report in text format</p>
|
410
|
-
</dd><dt><a href="RubyProf/FlatPrinterWithLineNumbers.html">RubyProf::FlatPrinterWithLineNumbers</a>
|
411
|
-
<dd>
|
412
|
-
<p>Same as above but more verbose</p>
|
413
|
-
</dd><dt><a href="RubyProf/GraphPrinter.html">RubyProf::GraphPrinter</a>
|
414
|
-
<dd>
|
415
|
-
<p>Creates a call graph report in text format</p>
|
416
|
-
</dd><dt><a href="RubyProf/GraphHtmlPrinter.html">RubyProf::GraphHtmlPrinter</a>
|
417
|
-
<dd>
|
418
|
-
<p>Creates a call graph report in HTML (separate files per thread)</p>
|
419
|
-
</dd><dt><a href="RubyProf/DotPrinter.html">RubyProf::DotPrinter</a>
|
420
|
-
<dd>
|
421
|
-
<p>Creates a call graph report in GraphViz's DOT format which can be
|
422
|
-
converted to an image</p>
|
423
|
-
</dd><dt><a href="RubyProf/CallTreePrinter.html">RubyProf::CallTreePrinter</a>
|
424
|
-
<dd>
|
425
|
-
<p>Creates a call tree report compatible with KCachegrind</p>
|
426
|
-
</dd><dt><a href="RubyProf/CallStackPrinter.html">RubyProf::CallStackPrinter</a>
|
427
|
-
<dd>
|
428
|
-
<p>Creates a HTML visualization of the Ruby stack</p>
|
429
|
-
</dd><dt><a href="RubyProf/MultiPrinter.html">RubyProf::MultiPrinter</a>
|
430
|
-
<dd>
|
431
|
-
<p>Uses the other printers to create several reports in one profiling run</p>
|
432
|
-
</dd></dl>
|
433
|
-
|
434
|
-
<p>To use a printer:</p>
|
435
|
-
|
436
|
-
<pre class="ruby"><span class="ruby-identifier">result</span> = <span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">stop</span>
|
437
|
-
<span class="ruby-identifier">printer</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GraphPrinter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">result</span>)
|
438
|
-
<span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(<span class="ruby-constant">STDOUT</span>, :<span class="ruby-identifier">min_percent</span> =<span class="ruby-operator">></span> <span class="ruby-value">2</span>)
|
439
|
-
</pre>
|
440
|
-
|
441
|
-
<p>The first parameter is any writable IO object such as <code>STDOUT</code>
|
442
|
-
or a file. The second parameter, specifies the minimum percentage a method
|
443
|
-
must take to be printed. Percentages should be specified as integers in
|
444
|
-
the range 0 to 100. For more information please see the documentation for
|
445
|
-
the different printers.</p>
|
446
|
-
|
447
|
-
<p>The other option is <code>:print_file => true</code> (default false),
|
448
|
-
which adds the filename to the output (GraphPrinter only).</p>
|
449
|
-
|
450
|
-
<p><code>MultiPrinter</code> differs from the other printers in that it
|
451
|
-
requires a directory path and a basename for the files it produces.</p>
|
452
|
-
|
453
|
-
<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>)
|
454
|
-
<span class="ruby-identifier">printer</span>.<span class="ruby-identifier">print</span>(:<span class="ruby-identifier">path</span> =<span class="ruby-operator">></span> <span class="ruby-string">"."</span>, :<span class="ruby-identifier">profile</span> =<span class="ruby-operator">></span> <span class="ruby-string">"profile"</span>)
|
455
|
-
</pre>
|
456
|
-
|
457
|
-
<h2 id="label-Measurements">Measurements<span><a href="#label-Measurements">¶</a> <a href="#top">↑</a></span></h2>
|
458
|
-
|
459
|
-
<p>Depending on the mode and platform, ruby-prof can measure various aspects
|
460
|
-
of a Ruby program. Supported measurements include:</p>
|
461
|
-
<dl class="rdoc-list note-list"><dt>RubyProf::WALL_TIME
|
462
|
-
<dd>
|
463
|
-
<p>Wall time measures the real-world time elapsed between any two moments. If
|
464
|
-
there are other processes concurrently running on the system that use
|
465
|
-
significant CPU or disk time during a profiling run then the reported
|
466
|
-
results will be larger than expected.</p>
|
467
|
-
</dd><dt>RubyProf::PROCESS_TIME
|
468
|
-
<dd>
|
469
|
-
<p>Process time measures the time used by a process between any two moments.
|
470
|
-
It is unaffected by other processes concurrently running on the system.
|
471
|
-
Note that Windows does not support measuring process times.</p>
|
472
|
-
</dd><dt>RubyProf::CPU_TIME
|
473
|
-
<dd>
|
474
|
-
<p>CPU time uses the CPU clock counter to measure time. The returned values
|
475
|
-
are dependent on the correctly setting the CPU's frequency. This mode
|
476
|
-
is only supported on Pentium or PowerPC platforms (linux only).</p>
|
477
|
-
</dd><dt>RubyProf::ALLOCATIONS
|
478
|
-
<dd>
|
479
|
-
<p>Object allocation reports show how many objects each method in a program
|
480
|
-
allocates. This support was added by Sylvain Joyeux and requires a patched
|
481
|
-
Ruby interpreter. See below.</p>
|
482
|
-
</dd><dt>RubyProf::MEMORY
|
483
|
-
<dd>
|
484
|
-
<p>Memory usage reports show how much memory each method in a program uses.
|
485
|
-
This support was added by Alexander Dymo and requires a patched Ruby
|
486
|
-
interpreter. See below.</p>
|
487
|
-
</dd><dt>RubyProf::GC_TIME
|
488
|
-
<dd>
|
489
|
-
<p>Garbage collection time reports how much time is spent in Ruby's
|
490
|
-
garbage collector during a profiling session. This support was added by
|
491
|
-
Jeremy Kemper and requires a patched Ruby interpreter. See below.</p>
|
492
|
-
</dd><dt>RubyProf::GC_RUNS
|
493
|
-
<dd>
|
494
|
-
<p>Garbage collection runs report how many times Ruby's garbage collector
|
495
|
-
is invoked during a profiling session. This support was added by Jeremy
|
496
|
-
Kemper and requires a patched Ruby interpreter. See below.</p>
|
497
|
-
</dd></dl>
|
498
|
-
|
499
|
-
<h2 id="label-Patching+ruby">Patching ruby<span><a href="#label-Patching+ruby">¶</a> <a href="#top">↑</a></span></h2>
|
500
|
-
|
501
|
-
<p>All of the patches to Ruby are included in the railsexpress patchsets for
|
502
|
-
rvm, see <a
|
503
|
-
href="https://github.com/skaes/rvm-patchsets">github.com/skaes/rvm-patchsets</a>.
|
504
|
-
You can also use these patches manually with other ruby managers
|
505
|
-
(ruby-install, ruby-build, etc.).</p>
|
506
|
-
|
507
|
-
<p>Note if you rebuild your ruby with patches you must uninstall and reinstall
|
508
|
-
the ruby-prof gem to take advantage of the new capabilities.</p>
|
509
|
-
|
510
|
-
<h2 id="label-Measure+modes">Measure modes<span><a href="#label-Measure+modes">¶</a> <a href="#top">↑</a></span></h2>
|
511
|
-
|
512
|
-
<p>To set the measurement:</p>
|
513
|
-
|
514
|
-
<pre class="ruby"><span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">WALL_TIME</span>
|
515
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">PROCESS_TIME</span>
|
516
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">CPU_TIME</span>
|
517
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">ALLOCATIONS</span>
|
518
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">MEMORY</span>
|
519
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GC_TIME</span>
|
520
|
-
<span class="ruby-constant">RubyProf</span>.<span class="ruby-identifier">measure_mode</span> = <span class="ruby-constant">RubyProf</span><span class="ruby-operator">::</span><span class="ruby-constant">GC_RUNS</span>
|
521
|
-
</pre>
|
522
|
-
|
523
|
-
<p>The default value is <code>RubyProf::WALL_TIME</code>.</p>
|
524
|
-
|
525
|
-
<p>You may also specify the measure mode by using the
|
526
|
-
<code>RUBY_PROF_MEASURE_MODE</code> environment variable:</p>
|
527
|
-
|
528
|
-
<pre class="ruby"><span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">wall</span>
|
529
|
-
<span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">process</span>
|
530
|
-
<span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">cpu</span>
|
531
|
-
<span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">allocations</span>
|
532
|
-
<span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">memory</span>
|
533
|
-
<span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">gc_time</span>
|
534
|
-
<span class="ruby-identifier">export</span> <span class="ruby-constant">RUBY_PROF_MEASURE_MODE</span>=<span class="ruby-identifier">gc_runs</span>
|
535
|
-
</pre>
|
536
|
-
|
537
|
-
<p>On Linux, process time is measured using the clock method provided by the C
|
538
|
-
runtime library. Note that the clock method does not report time spent in
|
539
|
-
the kernel or child processes and therefore does not measure time spent in
|
540
|
-
methods such as Kernel.sleep method. If you need to measure these values,
|
541
|
-
then use wall time. Wall time is measured using the gettimeofday kernel
|
542
|
-
method.</p>
|
543
|
-
|
544
|
-
<p>If you set the clock mode to <code>PROCESS_TIME</code>, then timings are
|
545
|
-
read using the clock method provided by the C runtime library. Note
|
546
|
-
though, these values are wall times on Windows and not process times like
|
547
|
-
on Linux. Wall time is measured using the GetLocalTime API.</p>
|
548
|
-
|
549
|
-
<p>If you use wall time, the results will be affected by other processes
|
550
|
-
running on your computer, network delays, disk access, etc. As result, for
|
551
|
-
the best results, try to make sure your computer is only performing your
|
552
|
-
profiling run and is otherwise quiescent.</p>
|
553
|
-
|
554
|
-
<h2 id="label-Multi-threaded+Applications">Multi-threaded Applications<span><a href="#label-Multi-threaded+Applications">¶</a> <a href="#top">↑</a></span></h2>
|
555
|
-
|
556
|
-
<p>Unfortunately, Ruby does not provide an internal API for detecting thread
|
557
|
-
context switches. As a result, the timings ruby-prof reports for each
|
558
|
-
thread may be slightly inaccurate. In particular, this will happen for
|
559
|
-
newly spawned threads that go to sleep immediately (their first call). For
|
560
|
-
instance, if you use Ruby's timeout library to wait for 2 seconds, the
|
561
|
-
2 seconds will be assigned to the foreground thread and not the newly
|
562
|
-
created background thread. These errors can largely be avoided if the
|
563
|
-
background thread performs any operation before going to sleep.</p>
|
564
|
-
|
565
|
-
<h2 id="label-Performance">Performance<span><a href="#label-Performance">¶</a> <a href="#top">↑</a></span></h2>
|
566
|
-
|
567
|
-
<p>Significant effort has been put into reducing ruby-prof's overhead as
|
568
|
-
much as possible. Our tests show that the overhead associated with
|
569
|
-
profiling code varies considerably with the code being profiled. Most
|
570
|
-
programs will run approximately twice as slow while highly recursive
|
571
|
-
programs (like the fibonacci series test) will run three times slower.</p>
|
572
|
-
|
573
|
-
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#top">↑</a></span></h2>
|
574
|
-
|
575
|
-
<p>See <a href="LICENSE.html">LICENSE</a> for license information.</p>
|
576
|
-
|
577
|
-
<h2 id="label-API+Documentation">API Documentation<span><a href="#label-API+Documentation">¶</a> <a href="#top">↑</a></span></h2>
|
578
|
-
|
579
|
-
<p>The ruby-prof API documentation for the latest released gem version can be
|
580
|
-
found here: <a
|
581
|
-
href="http://www.rubydoc.info/gems/ruby-prof">www.rubydoc.info/gems/ruby-prof</a>/</p>
|
582
|
-
|
583
|
-
<p>The ruby-prof API documentation for the master branch is available here: <a
|
584
|
-
href="http://www.rubydoc.info/github/ruby-prof/ruby-prof">www.rubydoc.info/github/ruby-prof/ruby-prof</a>/</p>
|
585
|
-
|
586
|
-
<h2 id="label-Development">Development<span><a href="#label-Development">¶</a> <a href="#top">↑</a></span></h2>
|
587
|
-
|
588
|
-
<p>Code is located at <a
|
589
|
-
href="https://github.com/ruby-prof/ruby-prof">github.com/ruby-prof/ruby-prof</a></p>
|
590
|
-
|
591
|
-
<p>Google group/mailing list: <a
|
592
|
-
href="http://groups.google.com/group/ruby-optimization">groups.google.com/group/ruby-optimization</a>
|
593
|
-
or open a github issue.</p>
|
594
|
-
</main>
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
<footer id="validator-badges" role="contentinfo">
|
599
|
-
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
600
|
-
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.2.
|
601
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
602
|
-
</footer>
|
603
|
-
|