ruby-prof 0.4.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CHANGES +17 -0
  2. data/LICENSE +23 -0
  3. data/README +220 -0
  4. data/Rakefile +141 -0
  5. data/bin/ruby-prof +154 -0
  6. data/doc/classes/RubyProf.html +563 -0
  7. data/doc/classes/RubyProf/CallInfo.html +274 -0
  8. data/doc/classes/RubyProf/FlatPrinter.html +207 -0
  9. data/doc/classes/RubyProf/GraphHtmlPrinter.html +538 -0
  10. data/doc/classes/RubyProf/GraphPrinter.html +240 -0
  11. data/doc/classes/RubyProf/MethodInfo.html +556 -0
  12. data/doc/classes/RubyProf/ProfileTask.html +395 -0
  13. data/doc/classes/RubyProf/Result.html +234 -0
  14. data/doc/created.rid +1 -0
  15. data/doc/files/LICENSE.html +142 -0
  16. data/doc/files/README.html +376 -0
  17. data/doc/files/bin/ruby-prof.html +143 -0
  18. data/doc/files/examples/flat_txt.html +187 -0
  19. data/doc/files/examples/graph_html.html +948 -0
  20. data/doc/files/examples/graph_txt.html +305 -0
  21. data/doc/files/ext/ruby_prof_c.html +101 -0
  22. data/doc/files/lib/ruby-prof/flat_printer_rb.html +101 -0
  23. data/doc/files/lib/ruby-prof/graph_html_printer_rb.html +108 -0
  24. data/doc/files/lib/ruby-prof/graph_printer_rb.html +101 -0
  25. data/doc/files/lib/ruby-prof/profiletask_rb.html +109 -0
  26. data/doc/files/lib/ruby-prof_rb.html +111 -0
  27. data/doc/files/lib/unprof_rb.html +108 -0
  28. data/doc/fr_class_index.html +34 -0
  29. data/doc/fr_file_index.html +39 -0
  30. data/doc/fr_method_index.html +67 -0
  31. data/doc/index.html +24 -0
  32. data/doc/rdoc-style.css +208 -0
  33. data/examples/flat.txt +57 -0
  34. data/examples/graph.html +827 -0
  35. data/examples/graph.txt +171 -0
  36. data/ext/extconf.rb +19 -0
  37. data/ext/ruby_prof.c +1433 -0
  38. data/lib/ruby-prof.rb +38 -0
  39. data/lib/ruby-prof/flat_printer.rb +76 -0
  40. data/lib/ruby-prof/graph_html_printer.rb +227 -0
  41. data/lib/ruby-prof/graph_printer.rb +142 -0
  42. data/lib/ruby-prof/profiletask.rb +150 -0
  43. data/lib/ruby_prof.so +0 -0
  44. data/lib/unprof.rb +8 -0
  45. data/test/basic_test.rb +141 -0
  46. data/test/clock_mode_test.rb +73 -0
  47. data/test/module_test.rb +45 -0
  48. data/test/prime.rb +58 -0
  49. data/test/prime_test.rb +24 -0
  50. data/test/printers_test.rb +28 -0
  51. data/test/recursive_test.rb +55 -0
  52. data/test/test.rb +3 -0
  53. data/test/test_helper.rb +45 -0
  54. data/test/test_suite.rb +9 -0
  55. data/test/thread_test.rb +32 -0
  56. data/test/timing_test.rb +90 -0
  57. metadata +122 -0
data/doc/created.rid ADDED
@@ -0,0 +1 @@
1
+ Wed Jun 21 01:45:05 Mountain Standard Time 2006
@@ -0,0 +1,142 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: LICENSE</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>LICENSE</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>LICENSE
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Sat Jun 17 04:03:12 Mountain Standard Time 2006</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <p>
73
+ Copyright (C) 2005 Shugo Maeda &lt;shugo@ruby-lang.org&gt; All rights
74
+ reserved.
75
+ </p>
76
+ <pre>
77
+ *
78
+ </pre>
79
+ <p>
80
+ Redistribution and use in source and binary forms, with or without
81
+ modification, are permitted provided that the following conditions are met:
82
+ </p>
83
+ <ol>
84
+ <li>Redistributions of source code must retain the above copyright notice, this
85
+ list of conditions and the following disclaimer.
86
+
87
+ </li>
88
+ <li>Redistributions in binary form must reproduce the above copyright notice,
89
+ this list of conditions and the following disclaimer in the documentation
90
+ and/or other materials provided with the distribution.
91
+
92
+ </li>
93
+ </ol>
94
+ <pre>
95
+ *
96
+ </pre>
97
+ <p>
98
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS
99
+ IS&#8217;&#8217; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
100
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
101
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
102
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
103
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
104
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
105
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
106
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
107
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
108
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109
+ </p>
110
+
111
+ </div>
112
+
113
+
114
+ </div>
115
+
116
+
117
+ </div>
118
+
119
+
120
+ <!-- if includes -->
121
+
122
+ <div id="section">
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ <!-- if method_list -->
132
+
133
+
134
+ </div>
135
+
136
+
137
+ <div id="validator-badges">
138
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
139
+ </div>
140
+
141
+ </body>
142
+ </html>
@@ -0,0 +1,376 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: README</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>README</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>README
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Tue Jun 20 23:21:24 Mountain Standard Time 2006</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h1>ruby-prof</h1>
73
+ <h2>Overview</h2>
74
+ <p>
75
+ ruby-prof is a fast code profiler for Ruby. Its features include:
76
+ </p>
77
+ <ul>
78
+ <li>Speed - it is a C extension and therefore many times faster than the
79
+ standard Ruby profiler.
80
+
81
+ </li>
82
+ <li>Flat Profiles - similar to the reports generated by the standard Ruby
83
+ profiler
84
+
85
+ </li>
86
+ <li>Graph profiles - similar to GProf, these show how long a method runs, which
87
+ methods call it and which methods it calls.
88
+
89
+ </li>
90
+ <li>Threads - supports profiling multiple threads simultaneously
91
+
92
+ </li>
93
+ <li>Recursive calls - supports profiling recursive method calls
94
+
95
+ </li>
96
+ <li>Reports - can generate both text and cross-referenced html reports
97
+
98
+ </li>
99
+ <li>Output - can output to standard out or to a file
100
+
101
+ </li>
102
+ </ul>
103
+ <h2>Requirements</h2>
104
+ <p>
105
+ ruby-prof requires Ruby 1.8.2 or higher.
106
+ </p>
107
+ <p>
108
+ If you are running Linux or Unix you&#8217;ll need a C compiler so the
109
+ extension can be compiled when it is installed.
110
+ </p>
111
+ <p>
112
+ If you are running Windows, then install the Windows specific RubyGem which
113
+ includes an already built extension.
114
+ </p>
115
+ <h2>Install</h2>
116
+ <p>
117
+ ruby-prof is provided as a RubyGem. To install:
118
+ </p>
119
+ <p>
120
+ <tt>gem install ruby-prof</tt>
121
+ </p>
122
+ <p>
123
+ If you are running Windows, make sure to install the Win32 RubyGem which
124
+ includes a pre-built binary.
125
+ </p>
126
+ <h2>Usage</h2>
127
+ <p>
128
+ There are three ways of running ruby-prof.
129
+ </p>
130
+ <h3>ruby-prof executable</h3>
131
+ <p>
132
+ The first is to use ruby-prof to run the Ruby program you want to profile.
133
+ For more information refer to the ruby-prof <a
134
+ href="bin/ruby-prof.html">documentation</a>.
135
+ </p>
136
+ <h3>ruby-prof API</h3>
137
+ <p>
138
+ The second way is to use the ruby-prof API to profile particular segments
139
+ of code.
140
+ </p>
141
+ <pre>
142
+ require 'ruby-prof'
143
+
144
+ # Profile the code
145
+ RubyProf.start
146
+ ...
147
+ [code to profile]
148
+ ...
149
+ result = RubyProf.end
150
+
151
+ # Print a flat profile to text
152
+ printer = RubyProf::TextPrinter.new(result)
153
+ printer.print(STDOUT, 0)
154
+ </pre>
155
+ <p>
156
+ Alternatively, you can use a block to tell ruby-prof what to profile:
157
+ </p>
158
+ <pre>
159
+ require 'ruby-prof'
160
+
161
+ # Profile the code
162
+ result = RubyProf.profile do
163
+ ...
164
+ [code to profile]
165
+ ...
166
+ end
167
+
168
+ # Print a graph profile to text
169
+ printer = RubyProf::GraphPrinter.new(result)
170
+ printer.print(STDOUT, 0)
171
+ </pre>
172
+ <h3>require unprof</h3>
173
+ <p>
174
+ The third way of using ruby-prof is by requiring unprof.rb:
175
+ </p>
176
+ <pre>
177
+ require 'unprof'
178
+ </pre>
179
+ <p>
180
+ This will start profiling immediately and will output the results using a
181
+ flat profile report.
182
+ </p>
183
+ <p>
184
+ This method is provided for backwards compatibility. Using <a
185
+ href="bin/ruby-prof.html">ruby-prof</a> provides more flexibility.
186
+ </p>
187
+ <h2>Reports</h2>
188
+ <p>
189
+ ruby-prof can generate flat profile and graph profile reports.
190
+ </p>
191
+ <p>
192
+ Flat profiles show the overall time spent in each method. They are a good
193
+ of quickly identifying which methods take the most time. An example of a
194
+ flat profile and an explanation can be found in <a
195
+ href="examples/flat_txt.html">examples/flat.txt</a>.
196
+ </p>
197
+ <p>
198
+ Graph profiles also show the overall time spent in each method. In
199
+ addition, they also show which methods call the current method and which
200
+ methods its calls. Thus they are good for understanding how methods gets
201
+ called and provide insight into the flow of your program. Graph profiles
202
+ can be generated in text and html. Since the html is cross-referenced it is
203
+ easier to work with. An example text graph profile is located at <a
204
+ href="examples/graph_txt.html">examples/graph.txt</a> while an example html
205
+ graph file is located at <a
206
+ href="examples/graph_html.html">examples/graph.html</a>.
207
+ </p>
208
+ <p>
209
+ Reports are created by printers. The current printers include:
210
+ </p>
211
+ <ul>
212
+ <li><a href="../classes/RubyProf/FlatPrinter.html">RubyProf::FlatPrinter</a> -
213
+ Creates a flat report in text format
214
+
215
+ </li>
216
+ <li><a href="../classes/RubyProf/GraphPrinter.html">RubyProf::GraphPrinter</a>
217
+ - Creates a call graph report in text format
218
+
219
+ </li>
220
+ <li><a
221
+ href="../classes/RubyProf/GraphHtmlPrinter.html">RubyProf::GraphHtmlPrinter</a>
222
+ - Creates a call graph report in HTML (separate files per thread)
223
+
224
+ </li>
225
+ </ul>
226
+ <p>
227
+ To use a printer:
228
+ </p>
229
+ <pre>
230
+ result = RubyProf.end
231
+ printer = RubyProf::GraphPrinter.new(result)
232
+ printer.print(STDOUT, 0)
233
+ </pre>
234
+ <p>
235
+ The first parameter is any writable IO object such as STDOUT or a file. The
236
+ second parameter, which has a default value of 0, specifies the minimum
237
+ percentage a method must take to be printed. For more information please
238
+ see the documentation for the different printers.
239
+ </p>
240
+ <h2>Timing Data</h2>
241
+ <p>
242
+ Depending on the mode and platform, ruby-prof can measure time in three
243
+ ways - process time, wall time and cpu time.
244
+ </p>
245
+ <p>
246
+ Process time measures the time used by a process between any two moments.
247
+ It is unaffected by other processes concurrently running on the system.
248
+ Note that Windows does not support measuring process times - therefore, all
249
+ measurements on Windows use wall time.
250
+ </p>
251
+ <p>
252
+ Wall time measures the real-world time elapsed between any two moments. If
253
+ there are other processes concurrently running on the system that use
254
+ significant CPU or disk time during a profiling run then the reported
255
+ results will be too large.
256
+ </p>
257
+ <p>
258
+ CPU time uses the CPU clock counter to measure time. The returned values
259
+ are dependent on the correctly setting the CPU&#8217;s frequency. This mode
260
+ is only supported on Pentium or PowerPC platforms.
261
+ </p>
262
+ <p>
263
+ To set the clock_mode:
264
+ </p>
265
+ <pre>
266
+ RubyProf.clock_mode = RubyProf::PROCESS_TIME
267
+ RubyProf.clock_mode = RubyProf::WALL_TIME
268
+ RubyProf.clock_mode = RubyProf::CPU_TIME
269
+ </pre>
270
+ <p>
271
+ This default value is PROCESS_TIME.
272
+ </p>
273
+ <p>
274
+ You may also specify the clock_mode by using the RUBY_PROF_CLOCK_MODE
275
+ environment variable:
276
+ </p>
277
+ <pre>
278
+ export RUBY_PROF_CLOCK_MODE=process
279
+ export RUBY_PROF_CLOCK_MODE=wall
280
+ export RUBY_PROF_CLOCK_MODE=cpu
281
+ </pre>
282
+ <p>
283
+ Note that these values have changed since ruby-prof-0.3.0.
284
+ </p>
285
+ <p>
286
+ On Linux, process time is measured using the clock method provided by the C
287
+ runtime library. Note that the clock method does not report time spent in
288
+ the kernel or child processes and therefore does not measure time spent in
289
+ methods such as Kernel.sleep method. If you need to measure these values,
290
+ then use wall time. Wall time is measured using the gettimeofday kernel
291
+ method.
292
+ </p>
293
+ <p>
294
+ On Windows, timings are always wall times. If you set the clock mode to
295
+ PROCESS_TIME, then timing are read using the clock method provided by the C
296
+ runtime library. Note though, these values are wall times on Windows and
297
+ not process times like on Linux. Wall time is measured using the
298
+ GetLocalTime API.
299
+ </p>
300
+ <p>
301
+ On both platforms, cpu time is measured using the RDTSC assembly function
302
+ provided by the Pentium and PowerPC platforms. CPU time is dependent on the
303
+ cpu&#8217;s frequency. On Linux, ruby-prof attempts to read this value from
304
+ &quot;/proc/cpuinfo.&quot; On Windows, you must specify the clock
305
+ frequency. This can be done using the RUBY_PROF_CPU_FREQUENCY environment
306
+ variable:
307
+ </p>
308
+ <pre>
309
+ export RUBY_PROF_CPU_FREQUENCY=&lt;value&gt;
310
+ </pre>
311
+ <p>
312
+ You can also directly set the cpu frequency by calling:
313
+ </p>
314
+ <pre>
315
+ RubyProf.cpu_frequency = &lt;value&gt;
316
+ </pre>
317
+ <h2>Recursive Calls</h2>
318
+ <p>
319
+ Recursive calls occur when method A calls method A and cycles occur when
320
+ method A calls method B calls method C calls method A. ruby-prof can detect
321
+ recursive calls any cycle calls, but does not currently report these in its
322
+ output.
323
+ </p>
324
+ <p>
325
+ However, the self time values for recursive calls should always be
326
+ accurate. It is also believed that the total times are accurate, but these
327
+ should be carefully analyzed to verify their veracity.
328
+ </p>
329
+ <h2>Performance</h2>
330
+ <p>
331
+ Significant effort has been put into reducing ruby-prof&#8217;s overhead as
332
+ much as possible. Our tests show that the overhead associated with
333
+ profiling code varies considerably with the code being profiled. On the low
334
+ end overhead is around 10% while on the high end its can around 80%.
335
+ </p>
336
+ <h2>Windows Binary</h2>
337
+ <p>
338
+ The Windows binary is built with the latest version of MinGW.
339
+ </p>
340
+ <h2>License</h2>
341
+ <p>
342
+ See LICENSE for license information.
343
+ </p>
344
+
345
+ </div>
346
+
347
+
348
+ </div>
349
+
350
+
351
+ </div>
352
+
353
+
354
+ <!-- if includes -->
355
+
356
+ <div id="section">
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+ <!-- if method_list -->
366
+
367
+
368
+ </div>
369
+
370
+
371
+ <div id="validator-badges">
372
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
373
+ </div>
374
+
375
+ </body>
376
+ </html>