ruby-prof 0.10.8 → 0.11.0.rc1
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.
- data/CHANGES +38 -18
- data/LICENSE +4 -3
- data/README.rdoc +30 -66
- data/Rakefile +47 -54
- data/bin/ruby-prof +24 -4
- data/ext/ruby_prof/extconf.rb +9 -16
- data/ext/ruby_prof/rp_call_info.c +369 -0
- data/ext/ruby_prof/rp_call_info.h +46 -0
- data/ext/ruby_prof/rp_measure.c +48 -0
- data/ext/ruby_prof/rp_measure.h +45 -0
- data/ext/ruby_prof/rp_measure_allocations.c +86 -0
- data/ext/ruby_prof/rp_measure_cpu_time.c +112 -0
- data/ext/ruby_prof/rp_measure_gc_runs.c +87 -0
- data/ext/ruby_prof/rp_measure_gc_time.c +73 -0
- data/ext/ruby_prof/rp_measure_memory.c +81 -0
- data/ext/ruby_prof/rp_measure_process_time.c +71 -0
- data/ext/ruby_prof/rp_measure_wall_time.c +42 -0
- data/ext/ruby_prof/rp_method.c +363 -0
- data/ext/ruby_prof/rp_method.h +55 -0
- data/ext/ruby_prof/rp_stack.c +61 -0
- data/ext/ruby_prof/rp_stack.h +40 -0
- data/ext/ruby_prof/rp_thread.c +113 -0
- data/ext/ruby_prof/rp_thread.h +20 -0
- data/ext/ruby_prof/ruby_prof.c +259 -1398
- data/ext/ruby_prof/ruby_prof.h +54 -190
- data/ext/ruby_prof/version.h +6 -3
- data/lib/1.8/ruby_prof.so +0 -0
- data/lib/1.9/ruby_prof.exp +0 -0
- data/lib/1.9/ruby_prof.ilk +0 -0
- data/lib/1.9/ruby_prof.lib +0 -0
- data/lib/1.9/ruby_prof.pdb +0 -0
- data/lib/1.9/ruby_prof.so +0 -0
- data/lib/ruby-prof.rb +14 -11
- data/lib/ruby-prof/abstract_printer.rb +10 -0
- data/lib/ruby-prof/aggregate_call_info.rb +2 -0
- data/lib/ruby-prof/call_info.rb +2 -0
- data/lib/ruby-prof/call_stack_printer.rb +2 -4
- data/lib/ruby-prof/call_tree_printer.rb +1 -0
- data/lib/ruby-prof/compatibility.rb +134 -0
- data/lib/ruby-prof/dot_printer.rb +7 -7
- data/lib/ruby-prof/flat_printer.rb +7 -7
- data/lib/ruby-prof/flat_printer_with_line_numbers.rb +2 -5
- data/lib/ruby-prof/graph_html_printer.rb +4 -2
- data/lib/ruby-prof/graph_printer.rb +4 -3
- data/lib/ruby-prof/method_info.rb +2 -0
- data/lib/ruby-prof/multi_printer.rb +2 -0
- data/lib/ruby-prof/{result.rb → profile.rb} +3 -1
- data/lib/ruby-prof/rack.rb +1 -0
- data/lib/ruby-prof/symbol_to_proc.rb +2 -0
- data/lib/ruby-prof/task.rb +1 -0
- data/lib/ruby-prof/test.rb +2 -0
- data/lib/ruby_prof.exp +0 -0
- data/lib/ruby_prof.ilk +0 -0
- data/lib/ruby_prof.lib +0 -0
- data/lib/ruby_prof.pdb +0 -0
- data/lib/ruby_prof.so +0 -0
- data/lib/unprof.rb +2 -0
- data/test/aggregate_test.rb +8 -8
- data/test/basic_test.rb +3 -251
- data/test/bug_test.rb +6 -0
- data/test/duplicate_names_test.rb +2 -2
- data/test/dynamic_method_test.rb +61 -0
- data/test/enumerable_test.rb +2 -2
- data/test/exceptions_test.rb +4 -3
- data/test/exclude_threads_test.rb +2 -2
- data/test/exec_test.rb +3 -3
- data/test/line_number_test.rb +5 -5
- data/test/measure_allocations_test.rb +25 -0
- data/test/measure_cpu_time_test.rb +212 -0
- data/test/measure_gc_runs_test.rb +29 -0
- data/test/measure_gc_time_test.rb +29 -0
- data/test/measure_memory_test.rb +36 -0
- data/test/measure_process_time_test.rb +205 -0
- data/test/measure_wall_time_test.rb +209 -0
- data/test/method_elimination_test.rb +2 -2
- data/test/module_test.rb +3 -2
- data/test/multi_printer_test.rb +2 -2
- data/test/no_method_class_test.rb +3 -1
- data/test/prime_test.rb +3 -3
- data/test/printers_test.rb +106 -8
- data/test/recursive_test.rb +7 -6
- data/test/singleton_test.rb +2 -2
- data/test/stack_printer_test.rb +2 -3
- data/test/stack_test.rb +2 -2
- data/test/start_stop_test.rb +2 -2
- data/test/test_helper.rb +81 -0
- data/test/test_suite.rb +34 -29
- data/test/thread_test.rb +24 -23
- data/test/unique_call_path_test.rb +2 -2
- metadata +101 -69
- data/ext/ruby_prof/measure_allocations.h +0 -83
- data/ext/ruby_prof/measure_cpu_time.h +0 -152
- data/ext/ruby_prof/measure_gc_runs.h +0 -76
- data/ext/ruby_prof/measure_gc_time.h +0 -57
- data/ext/ruby_prof/measure_memory.h +0 -101
- data/ext/ruby_prof/measure_process_time.h +0 -63
- data/ext/ruby_prof/measure_wall_time.h +0 -53
- data/ext/ruby_prof/mingw/Rakefile +0 -23
- data/ext/ruby_prof/mingw/build.rake +0 -38
- data/rails/environment/profile.rb +0 -24
- data/rails/example/example_test.rb +0 -9
- data/rails/profile_test_helper.rb +0 -21
- data/test/current_failures_windows +0 -8
- data/test/measurement_test.rb +0 -132
- data/test/ruby-prof-bin +0 -20
data/CHANGES
CHANGED
|
@@ -1,48 +1,68 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.11.0.rc1 (2012-03-24)
|
|
2
2
|
======================
|
|
3
|
-
|
|
3
|
+
* On Windows, use QueryPerformanceCounter and QueryPerformanceFrequency to measure CPU time instead
|
|
4
|
+
of rdtsc. This change is based on Microsoft's recommendation (Charlie Savage).
|
|
5
|
+
* On Windows use GetProcessTimes to return real PROCESS_TIME times instead of wall times (Charlie Savage).
|
|
6
|
+
* Big internal refactoring of C code to make RubyProf easier to understand and extend (Charlie Savage).
|
|
7
|
+
* Profile results are now returned as instances of a new class RubyProf::Profile. The old api
|
|
8
|
+
is supported via a compatability layer that at some point will be deprecated. (Charlie Savage).
|
|
9
|
+
* Split out tests for cpu_time, process_time and wall_time into separate files (Charlie Savage).
|
|
10
|
+
* Dropped support for Ruby 1.8.4 and 1.8.6 - does anybody still use these? (Charlie Savage).
|
|
11
|
+
* Added support for sorting results by total, self, wait and child times (Jan Suchal)
|
|
12
|
+
* Added tests for sorting behaviour & removed options from constructor to print method (Jan Suchal)
|
|
13
|
+
* Fix line number tests due to changes at top of file (Charlie Savage).
|
|
14
|
+
* Add encoding statement to top of all files for Ruby 1.9.x compatability (Charlie Savage).
|
|
15
|
+
* Add def file for VC to avoid the whole declspec annoyance (Charlie Savage).
|
|
16
|
+
* Update test suite to ensure current working directory is correct (Charlie Savage).
|
|
17
|
+
* Modernize gem file and remove various custom/home grown solutions that aren't needed anymore (Charlie Savage).
|
|
18
|
+
* Remove custom mingw build scripts, use rake compiler instead (Charlie Savage).
|
|
19
|
+
* Fixes for compiling with VC 2010 (Charlie Savage).
|
|
20
|
+
|
|
21
|
+
0.10.8 (2011-07-06)
|
|
22
|
+
======================
|
|
23
|
+
* 1.9.3 super class (Roger Pack)
|
|
4
24
|
|
|
5
|
-
0.10.7
|
|
25
|
+
0.10.7 (2011-05-09)
|
|
6
26
|
======================
|
|
7
|
-
Fix a bug with REE's GC stats. Issue #53 [thanks graaff]
|
|
27
|
+
* Fix a bug with REE's GC stats. Issue #53 [thanks graaff]
|
|
8
28
|
|
|
9
|
-
0.10.6
|
|
29
|
+
0.10.6 (2011-04-29)
|
|
10
30
|
======================
|
|
11
|
-
Slightly more normalized url for linux/windows links to files.
|
|
31
|
+
* Slightly more normalized url for linux/windows links to files.
|
|
12
32
|
|
|
13
|
-
0.10.5
|
|
33
|
+
0.10.5 (2011-04-20)
|
|
14
34
|
=======================
|
|
15
|
-
1.8.6 compat for -v command (bug fix)
|
|
35
|
+
* 1.8.6 compat for -v command (bug fix)
|
|
16
36
|
|
|
17
|
-
0.10.4
|
|
37
|
+
0.10.4 (2011-04-20)
|
|
18
38
|
=======================
|
|
19
|
-
Faster load time for ruby-prof itself.
|
|
39
|
+
* Faster load time for ruby-prof itself.
|
|
20
40
|
|
|
21
41
|
0.10.3
|
|
22
42
|
=======================
|
|
23
|
-
Can cleanly load before rubygems now.
|
|
43
|
+
* Can cleanly load before rubygems now.
|
|
24
44
|
|
|
25
45
|
0.10.2
|
|
26
46
|
=======================
|
|
27
|
-
Fix for 1.9.2, os x for latest commits (thanks skaes!)
|
|
47
|
+
* Fix for 1.9.2, os x for latest commits (thanks skaes!)
|
|
28
48
|
|
|
29
49
|
0.10.1
|
|
30
50
|
=======================
|
|
31
|
-
Fix bug in linux wall time, also load with only relative paths so that you can use it to benchmark rubygems startup overhead,
|
|
32
|
-
itself.
|
|
51
|
+
* Fix bug in linux wall time, also load with only relative paths so that you can use it to benchmark rubygems startup overhead,
|
|
52
|
+
itself.
|
|
33
53
|
|
|
34
54
|
0.10.0
|
|
35
55
|
=======================
|
|
36
|
-
Some rdoc changes, for linux wall time attempt to use higher granularity (thanks to all the contributors for this round!)
|
|
56
|
+
* Some rdoc changes, for linux wall time attempt to use higher granularity (thanks to all the contributors for this round!)
|
|
37
57
|
|
|
38
58
|
0.9.2
|
|
39
59
|
=======================
|
|
40
|
-
Make graphviz work on 1.8.6
|
|
41
|
-
|
|
60
|
+
* Make graphviz work on 1.8.6
|
|
61
|
+
* Roll back some 1.9.2 optimizations until I can figure out what caused them.
|
|
42
62
|
|
|
43
63
|
0.9.1
|
|
44
64
|
=======================
|
|
45
|
-
Add a graphviz output
|
|
65
|
+
* Add a graphviz output
|
|
46
66
|
|
|
47
67
|
0.9.0
|
|
48
68
|
=======================
|
data/LICENSE
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
Copyright (C) 2005
|
|
1
|
+
Copyright (C) 2005 - 20011 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
|
|
2
2
|
All rights reserved.
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
Redistribution and use in source and binary forms, with or without
|
|
5
5
|
modification, are permitted provided that the following conditions
|
|
6
6
|
are met:
|
|
7
|
+
|
|
7
8
|
1. Redistributions of source code must retain the above copyright
|
|
8
9
|
notice, this list of conditions and the following disclaimer.
|
|
9
10
|
2. Redistributions in binary form must reproduce the above copyright
|
|
10
11
|
notice, this list of conditions and the following disclaimer in the
|
|
11
12
|
documentation and/or other materials provided with the distribution.
|
|
12
|
-
|
|
13
|
+
|
|
13
14
|
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
14
15
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
15
16
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
data/README.rdoc
CHANGED
|
@@ -15,7 +15,7 @@ ruby-prof is a fast code profiler for Ruby. Its features include:
|
|
|
15
15
|
|
|
16
16
|
== Requirements
|
|
17
17
|
|
|
18
|
-
ruby-prof requires Ruby 1.8.
|
|
18
|
+
ruby-prof requires Ruby 1.8.7 or 1.9.1 and higher.
|
|
19
19
|
|
|
20
20
|
If you are running Linux or Unix you'll need a C compiler so the extension
|
|
21
21
|
can be compiled when it is installed.
|
|
@@ -29,16 +29,12 @@ The easiest way to install ruby-prof is by using Ruby Gems. To install:
|
|
|
29
29
|
|
|
30
30
|
gem install ruby-prof
|
|
31
31
|
|
|
32
|
-
If you on windows
|
|
33
|
-
|
|
34
|
-
has a prebuilt binary
|
|
35
|
-
C:> gem install ruby-prof -v0.8.1
|
|
36
|
-
|
|
37
|
-
If you're on mingw, please install the devkit first, then install the latest gem version (via gem install ruby-prof).
|
|
32
|
+
If you're on windows then a prebuilt binary gem is available. You may of course
|
|
33
|
+
compile it yourself via use of devkit on MinGW.
|
|
38
34
|
|
|
39
35
|
== Usage
|
|
40
36
|
|
|
41
|
-
There are
|
|
37
|
+
There are two ways of running ruby-prof, via the command line or via its API.
|
|
42
38
|
|
|
43
39
|
=== ruby-prof executable
|
|
44
40
|
|
|
@@ -81,8 +77,7 @@ to profile:
|
|
|
81
77
|
printer = RubyProf::GraphPrinter.new(result)
|
|
82
78
|
printer.print(STDOUT, {})
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
profiling runs.
|
|
80
|
+
ruby-prof also supports pausing and resuming profiling runs.
|
|
86
81
|
|
|
87
82
|
require 'ruby-prof'
|
|
88
83
|
|
|
@@ -110,18 +105,10 @@ has not yet started. In addition, resume can also take a block:
|
|
|
110
105
|
With this usage, resume will automatically call pause at the
|
|
111
106
|
end of the block.
|
|
112
107
|
|
|
113
|
-
=== require unprof
|
|
114
|
-
|
|
115
|
-
The third way of using ruby-prof is by requiring unprof.rb:
|
|
116
|
-
|
|
117
|
-
require 'unprof'
|
|
118
|
-
|
|
119
|
-
This will start profiling immediately at that point and will output the results
|
|
120
|
-
using a flat profile report when the process ends.
|
|
121
108
|
|
|
122
|
-
== Method Elimination
|
|
109
|
+
== Method and Thread Elimination
|
|
123
110
|
|
|
124
|
-
|
|
111
|
+
ruby-prof supports eliminating specific methods and threads from profiling
|
|
125
112
|
results. This is useful for reducing connectivity in the call graph, making it easier to
|
|
126
113
|
identify the source of performance problems when using a graph printer.
|
|
127
114
|
|
|
@@ -141,6 +128,15 @@ the name of a file containing a list of regular expressions (line separated text
|
|
|
141
128
|
After eliminating methods the resulting profile will appear exactly as if those methods
|
|
142
129
|
had been inlined at their call sites.
|
|
143
130
|
|
|
131
|
+
In a similar manner, threads can be excluded so they are not profiled at all. To do this,
|
|
132
|
+
pass an array of threads to exclude to ruby-prof:
|
|
133
|
+
|
|
134
|
+
RubyProf::exclude_threads = [ thread2 ]
|
|
135
|
+
RubyProf.start
|
|
136
|
+
|
|
137
|
+
Note that the excluded threads must be specified *before* profiling.
|
|
138
|
+
|
|
139
|
+
|
|
144
140
|
== Benchmarking full load time including rubygems startup cost ==
|
|
145
141
|
|
|
146
142
|
If you want to get a more accurate measurement of what takes all of a gem's bin/xxx
|
|
@@ -160,7 +156,7 @@ $ ruby g:/192/lib/ruby/gems/1.9.1/gems/ruby-prof-0.10.2/bin/ruby-prof ./some_fil
|
|
|
160
156
|
|
|
161
157
|
== Profiling Tests
|
|
162
158
|
|
|
163
|
-
|
|
159
|
+
ruby-prof supports profiling tests cases
|
|
164
160
|
written using Ruby's built-in unit test framework (ie, test derived from
|
|
165
161
|
Test::Unit::TestCase). To enable profiling simply add the following line
|
|
166
162
|
of code to within your test class:
|
|
@@ -189,49 +185,23 @@ profile.rb.
|
|
|
189
185
|
|
|
190
186
|
So to profile Rails:
|
|
191
187
|
|
|
192
|
-
1. Create a new profile.rb environment
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
2. Copy the file:
|
|
196
|
-
|
|
197
|
-
ruby-prof/rails/profile_test_helper.rb
|
|
198
|
-
|
|
199
|
-
To:
|
|
200
|
-
|
|
201
|
-
your_rails_app/test/profile_test_helper.rb
|
|
188
|
+
1. Create a new profile.rb environment. Make sure to turn on cache_classes
|
|
189
|
+
and cache_template_loading. Otherwise your profiling results will be
|
|
190
|
+
overwhelemed by the time Rails spends loading required files.
|
|
202
191
|
|
|
203
|
-
|
|
192
|
+
2. Add the ruby prof rack adapter to your middleware stack. One way to
|
|
193
|
+
do this is by adding the following code to config.ru:
|
|
204
194
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
4. Write unit, functional or integration tests specifically designed
|
|
209
|
-
to profile some part of your Rails application. At the top
|
|
210
|
-
of each test, replace this line:
|
|
211
|
-
|
|
212
|
-
require File.dirname(__FILE__) + '/../test_helper'
|
|
213
|
-
|
|
214
|
-
With:
|
|
215
|
-
|
|
216
|
-
require File.dirname(__FILE__) + '/../profile_test_helper'
|
|
217
|
-
|
|
218
|
-
For example:
|
|
219
|
-
|
|
220
|
-
require File.dirname(__FILE__) + '/../profile_test_helper'
|
|
221
|
-
|
|
222
|
-
class ExampleTest < Test::Unit::TestCase
|
|
223
|
-
include RubyProf::Test
|
|
224
|
-
fixtures ....
|
|
225
|
-
|
|
226
|
-
def test_stuff
|
|
227
|
-
puts "Test method"
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
5. Now run your tests. Results will be written to:
|
|
195
|
+
if Rails.env.profile?
|
|
196
|
+
use Rack::RubyProf, :path => '/temp/profile'
|
|
197
|
+
end
|
|
232
198
|
|
|
233
|
-
|
|
199
|
+
The path is where you want profiling results to be stored. By default the
|
|
200
|
+
rack adapter will generate a html call graph report and flat text report.
|
|
234
201
|
|
|
202
|
+
3. Now make a request to your running server. New profiling information will
|
|
203
|
+
be generated for each request. Note that each request will overwrite
|
|
204
|
+
the profiling reports created by the previous request!
|
|
235
205
|
|
|
236
206
|
== Reports
|
|
237
207
|
|
|
@@ -389,8 +359,6 @@ environment variable:
|
|
|
389
359
|
* export RUBY_PROF_MEASURE_MODE=gc_runs
|
|
390
360
|
* export RUBY_PROF_MEASURE_MODE=gc_time
|
|
391
361
|
|
|
392
|
-
Note that these values have changed since ruby-prof-0.3.0.
|
|
393
|
-
|
|
394
362
|
On Linux, process time is measured using the clock method provided
|
|
395
363
|
by the C runtime library. Note that the clock method does not
|
|
396
364
|
report time spent in the kernel or child processes and therefore
|
|
@@ -446,10 +414,6 @@ profiled. Most programs will run approximately twice as slow
|
|
|
446
414
|
while highly recursive programs (like the fibonacci series test)
|
|
447
415
|
will run three times slower.
|
|
448
416
|
|
|
449
|
-
Because of some threading difficulties in 1.9, it currently runs a
|
|
450
|
-
bit slower there, as well.
|
|
451
|
-
http://www.ruby-forum.com/topic/201329
|
|
452
|
-
|
|
453
417
|
== License
|
|
454
418
|
|
|
455
419
|
See LICENSE for license information.
|
data/Rakefile
CHANGED
|
@@ -1,38 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
require 'rake/gempackagetask'
|
|
3
|
-
require 'rake/rdoctask'
|
|
4
|
-
require 'rake/testtask'
|
|
5
|
-
require 'date'
|
|
1
|
+
# encoding: utf-8
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
require "rubygems/package_task"
|
|
4
|
+
require "rake/extensiontask"
|
|
5
|
+
require "rake/testtask"
|
|
6
|
+
require "rdoc/task"
|
|
7
|
+
require "date"
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
# To release a version of ruby-prof:
|
|
10
|
+
# * Update version.h
|
|
11
|
+
# * Update CHANGES
|
|
12
|
+
# * Update rdocs
|
|
13
|
+
# * git commit to commit files
|
|
14
|
+
# * rake clobber to remove extra files
|
|
15
|
+
# * rake compile to build windows gems
|
|
16
|
+
# * rake package to create the gems
|
|
17
|
+
# * Tag the release in git (tag 0.10.1)
|
|
18
|
+
# * Push to ruybgems.org (gem push pkg/<gem files>)
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
GEM_NAME = 'ruby-prof'
|
|
21
|
+
SO_NAME = 'ruby_prof'
|
|
22
|
+
|
|
23
|
+
default_spec = Gem::Specification.load("#{GEM_NAME}.gemspec")
|
|
24
|
+
|
|
25
|
+
Rake::ExtensionTask.new do |ext|
|
|
26
|
+
ext.gem_spec = default_spec
|
|
27
|
+
ext.name = SO_NAME
|
|
28
|
+
ext.ext_dir = "ext/#{SO_NAME}"
|
|
29
|
+
ext.lib_dir = "lib/#{RUBY_VERSION.sub(/\.\d$/, '')}"
|
|
30
|
+
ext.cross_compile = true
|
|
31
|
+
ext.cross_platform = ['x86-mswin32-60', 'x86-mingw32-60']
|
|
24
32
|
end
|
|
25
33
|
|
|
26
34
|
# Rake task to build the default package
|
|
27
|
-
|
|
35
|
+
Gem::PackageTask.new(default_spec) do |pkg|
|
|
28
36
|
pkg.need_tar = true
|
|
29
|
-
#pkg.need_zip = true
|
|
30
37
|
end
|
|
31
38
|
|
|
39
|
+
# Setup Windows Gem
|
|
40
|
+
if RUBY_PLATFORM.match(/win32|mingw32/)
|
|
41
|
+
# Windows specification
|
|
42
|
+
win_spec = default_spec.clone
|
|
43
|
+
win_spec.platform = Gem::Platform::CURRENT
|
|
44
|
+
win_spec.files += Dir.glob('lib/**/*.so')
|
|
45
|
+
win_spec.instance_variable_set(:@cache_file, nil) # Hack to work around gem issue
|
|
46
|
+
|
|
47
|
+
# Unset extensions
|
|
48
|
+
win_spec.extensions = nil
|
|
49
|
+
|
|
50
|
+
# Rake task to build the windows package
|
|
51
|
+
Gem::PackageTask.new(win_spec) do |pkg|
|
|
52
|
+
pkg.need_tar = false
|
|
53
|
+
end
|
|
54
|
+
end
|
|
32
55
|
|
|
33
56
|
# --------- RDoc Documentation ------
|
|
34
57
|
desc "Generate rdoc documentation"
|
|
35
|
-
|
|
58
|
+
RDoc::Task.new("rdoc") do |rdoc|
|
|
36
59
|
rdoc.rdoc_dir = 'doc'
|
|
37
60
|
rdoc.title = "ruby-prof"
|
|
38
61
|
# Show source inline with line numbers
|
|
@@ -60,34 +83,4 @@ Rake::TestTask.new do |t|
|
|
|
60
83
|
t.test_files = Dir['test/test_suite.rb']
|
|
61
84
|
t.verbose = true
|
|
62
85
|
t.warning = true
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
require 'fileutils'
|
|
66
|
-
|
|
67
|
-
desc 'Build ruby_prof.so'
|
|
68
|
-
task :build do
|
|
69
|
-
Dir.chdir('ext/ruby_prof') do
|
|
70
|
-
unless File.exist? 'Makefile'
|
|
71
|
-
system(Gem.ruby + " extconf.rb")
|
|
72
|
-
system("make clean")
|
|
73
|
-
end
|
|
74
|
-
raise 'make failed' unless system("make")
|
|
75
|
-
FileUtils.cp 'ruby_prof.so', '../../lib' if File.exist? 'lib/ruby_prof.so'
|
|
76
|
-
FileUtils.cp 'ruby_prof.bundle', '../../lib' if File.exist? 'lib/ruby_prof.bundle'
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
desc 'clean stuff'
|
|
81
|
-
task :cleanr do
|
|
82
|
-
Dir['**/*.{so,bundle}'].each{|f| File.delete f}
|
|
83
|
-
Dir.chdir('ext/ruby_prof') do
|
|
84
|
-
if File.exist? 'Makefile'
|
|
85
|
-
system("make clean")
|
|
86
|
-
FileUtils.rm 'Makefile'
|
|
87
|
-
end
|
|
88
|
-
Dir.glob('*~') do |file|
|
|
89
|
-
FileUtils.rm file
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
system("rm -rf pkg")
|
|
93
|
-
end
|
|
86
|
+
end
|
data/bin/ruby-prof
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
require 'ostruct'
|
|
17
17
|
require 'optparse'
|
|
18
|
-
require File.
|
|
18
|
+
require File.expand_path('../../lib/ruby-prof', __FILE__)
|
|
19
19
|
|
|
20
20
|
options = OpenStruct.new
|
|
21
21
|
options.measure_mode = RubyProf::PROCESS_TIME
|
|
@@ -104,7 +104,26 @@ opts = OptionParser.new do |opts|
|
|
|
104
104
|
options.measure_mode = RubyProf::GC_TIME
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
|
-
|
|
107
|
+
|
|
108
|
+
opts.on('-s sort_mode', '--sort=sort_mode', [:total, :self, :wait, :child],
|
|
109
|
+
'Select how ruby-prof results should be sorted:',
|
|
110
|
+
' total - Total time',
|
|
111
|
+
' self - Self time',
|
|
112
|
+
' wait - Wait time',
|
|
113
|
+
' child - Child time') do |sort_mode|
|
|
114
|
+
|
|
115
|
+
options.sort_method = case sort_mode
|
|
116
|
+
when :total
|
|
117
|
+
:total_time
|
|
118
|
+
when :self
|
|
119
|
+
:self_time
|
|
120
|
+
when :wait
|
|
121
|
+
:wait_time
|
|
122
|
+
when :child
|
|
123
|
+
:children_time
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
108
127
|
opts.on("--replace-progname", "Replace $0 when loading the .rb files.") do
|
|
109
128
|
options.replace_prog_name = true
|
|
110
129
|
end
|
|
@@ -184,18 +203,19 @@ at_exit {
|
|
|
184
203
|
|
|
185
204
|
# Create a printer
|
|
186
205
|
printer = options.printer.new(result)
|
|
206
|
+
printer_options = {:min_percent => options.min_percent, :sort_method => options.sort_method}
|
|
187
207
|
|
|
188
208
|
# Get output
|
|
189
209
|
if options.file
|
|
190
210
|
# write it relative to the dir they *started* in, as it's a bit surprising to write it in the dir they end up in.
|
|
191
211
|
Dir.chdir(options.old_wd) do
|
|
192
212
|
File.open(options.file, 'w') do |file|
|
|
193
|
-
printer.print(file,
|
|
213
|
+
printer.print(file, printer_options)
|
|
194
214
|
end
|
|
195
215
|
end
|
|
196
216
|
else
|
|
197
217
|
# Print out results
|
|
198
|
-
printer.print(STDOUT,
|
|
218
|
+
printer.print(STDOUT, printer_options)
|
|
199
219
|
end
|
|
200
220
|
}
|
|
201
221
|
|