ruby-prof 0.4.1-mswin32 → 0.5.0-mswin32
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 +30 -0
- data/README +65 -25
- data/Rakefile +33 -32
- data/bin/ruby-prof +100 -83
- data/examples/graph.html +65 -69
- data/ext/measure_allocations.h +43 -0
- data/ext/measure_cpu_time.h +138 -0
- data/ext/measure_process_time.h +41 -0
- data/ext/measure_wall_time.h +42 -0
- data/ext/ruby_prof.c +737 -653
- data/lib/ruby-prof.rb +41 -38
- data/lib/ruby-prof/abstract_printer.rb +42 -0
- data/lib/ruby-prof/call_tree_printer.rb +69 -0
- data/lib/ruby-prof/flat_printer.rb +78 -75
- data/lib/ruby-prof/graph_html_printer.rb +241 -228
- data/lib/ruby-prof/graph_printer.rb +160 -141
- data/lib/ruby-prof/profile_test_case.rb +80 -0
- data/lib/ruby-prof/rails_plugin/ruby-prof/init.rb +6 -0
- data/lib/ruby-prof/rails_plugin/ruby-prof/lib/profiling.rb +52 -0
- data/lib/ruby-prof/task.rb +147 -0
- data/lib/ruby_prof.so +0 -0
- data/test/basic_test.rb +65 -35
- data/test/duplicate_names_test.rb +20 -24
- data/test/gc.log +5 -0
- data/test/measure_mode_test.rb +79 -0
- data/test/module_test.rb +31 -18
- data/test/no_method_class_test.rb +14 -0
- data/test/prime1.rb +17 -0
- data/test/prime2.rb +26 -0
- data/test/prime3.rb +17 -0
- data/test/prime_test.rb +10 -10
- data/test/printers_test.rb +14 -12
- data/test/profile_unit_test.rb +24 -0
- data/test/recursive_test.rb +105 -17
- data/test/singleton_test.rb +38 -0
- data/test/start_test.rb +24 -0
- data/test/test_helper.rb +33 -29
- data/test/test_suite.rb +10 -2
- data/test/thread_test.rb +123 -17
- data/test/timing_test.rb +70 -29
- metadata +28 -30
- data/doc/created.rid +0 -1
- data/doc/files/LICENSE.html +0 -0
- data/doc/files/README.html +0 -376
- data/doc/files/bin/ruby-prof.html +0 -143
- data/doc/files/examples/flat_txt.html +0 -179
- data/doc/files/examples/graph_html.html +0 -948
- data/doc/files/examples/graph_txt.html +0 -297
- data/doc/files/ext/ruby_prof_c.html +0 -101
- data/doc/files/lib/ruby-prof/flat_printer_rb.html +0 -101
- data/doc/files/lib/ruby-prof/graph_html_printer_rb.html +0 -108
- data/doc/files/lib/ruby-prof/graph_printer_rb.html +0 -101
- data/doc/files/lib/ruby-prof/profiletask_rb.html +0 -109
- data/doc/files/lib/ruby-prof_rb.html +0 -111
- data/doc/files/lib/unprof_rb.html +0 -108
- data/doc/rdoc-style.css +0 -208
- data/lib/ruby-prof/profiletask.rb +0 -150
- data/test/clock_mode_test.rb +0 -73
data/CHANGES
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
0.5.0 (?)
|
2
|
+
========================
|
3
|
+
|
4
|
+
Features
|
5
|
+
--------
|
6
|
+
* Added support for 64 bit systems (patch from Diego 'Flameeyes' Petten�)
|
7
|
+
* Added suport for outputting data in the format used by
|
8
|
+
KCacheGrind (patch from Carl Shimer)
|
9
|
+
* Add filename and line numbers to call tree information (patch from Carl Shimer)
|
10
|
+
* Added Visual Studio 2005 project file.
|
11
|
+
|
12
|
+
Fixes
|
13
|
+
-------
|
14
|
+
* Fixes a bug when the type of an attached object (singleton) is inherited
|
15
|
+
from T_OBJECT as opposed to being a T_OBJECT (identified by Francis Cianfrocca)
|
16
|
+
|
17
|
+
|
18
|
+
0.4.1 (2006-06-26)
|
19
|
+
========================
|
20
|
+
|
21
|
+
Features
|
22
|
+
--------
|
23
|
+
* Added a RubyProf.running? method to indicate whether a profile is in progress.
|
24
|
+
* Added tgz and zip archives to release
|
25
|
+
|
26
|
+
Fixes
|
27
|
+
-------
|
28
|
+
* Duplicate method names are now allowed
|
29
|
+
* The documentation has been updated to show the correct API usage is RubyProf.stop not RubyProf.end
|
30
|
+
|
1
31
|
|
2
32
|
0.4.0 (2006-06-16)
|
3
33
|
========================
|
data/README
CHANGED
@@ -7,6 +7,7 @@ ruby-prof is a fast code profiler for Ruby. Its features include:
|
|
7
7
|
* Speed - it is a C extension and therefore many times faster than the standard Ruby profiler.
|
8
8
|
* Flat Profiles - similar to the reports generated by the standard Ruby profiler
|
9
9
|
* Graph profiles - similar to GProf, these show how long a method runs, which methods call it and which methods it calls.
|
10
|
+
* Call tree profiles - outputs results in the calltree format suitable for the KCacheGrind profiling tool.
|
10
11
|
* Threads - supports profiling multiple threads simultaneously
|
11
12
|
* Recursive calls - supports profiling recursive method calls
|
12
13
|
* Reports - can generate both text and cross-referenced html reports
|
@@ -15,7 +16,7 @@ ruby-prof is a fast code profiler for Ruby. Its features include:
|
|
15
16
|
|
16
17
|
== Requirements
|
17
18
|
|
18
|
-
ruby-prof requires Ruby 1.8.
|
19
|
+
ruby-prof requires Ruby 1.8.4 or higher.
|
19
20
|
|
20
21
|
If you are running Linux or Unix you'll need a C compiler so the extension
|
21
22
|
can be compiled when it is installed.
|
@@ -93,7 +94,12 @@ This method is provided for backwards compatibility. Using
|
|
93
94
|
|
94
95
|
== Reports
|
95
96
|
|
96
|
-
ruby-prof can generate
|
97
|
+
ruby-prof can generate a number of different reports:
|
98
|
+
|
99
|
+
* Flat Reports
|
100
|
+
* Graph Reports
|
101
|
+
* HTML Graph Reports
|
102
|
+
* Call graphs
|
97
103
|
|
98
104
|
Flat profiles show the overall time spent in each method. They
|
99
105
|
are a good of quickly identifying which methods take the most time.
|
@@ -104,17 +110,34 @@ Graph profiles also show the overall time spent in each method.
|
|
104
110
|
In addition, they also show which methods call the current
|
105
111
|
method and which methods its calls. Thus they are good for
|
106
112
|
understanding how methods gets called and provide insight into
|
107
|
-
the flow of your program.
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
113
|
+
the flow of your program. An example text graph profile
|
114
|
+
is located at {examples/graph.txt}[link:files/examples/graph_txt.html].
|
115
|
+
|
116
|
+
HTML Graph profiles are the same as graph profiles, except
|
117
|
+
output is generated in hyper-linked HTML. Since graph profiles
|
118
|
+
can be quite large, the embedded links make it much easier to
|
119
|
+
navigate the results. An example html graph profile
|
120
|
+
is located at {examples/graph.html}[link:files/examples/graph_html.html].
|
121
|
+
|
122
|
+
HTML Graph profiles are the same as graph profiles, except
|
123
|
+
output is generated in hyper-linked HTML. Since graph profiles
|
124
|
+
can be quite large, the embedded links make it much easier to
|
125
|
+
navigate the results. An example html graph profile
|
126
|
+
is located at {examples/graph.html}[link:files/examples/graph_html.html].
|
127
|
+
|
128
|
+
Call graphs output results in the calltree profile format which is used
|
129
|
+
by KCachegrind. Call graph support was generously donated by Carl Shimer.
|
130
|
+
More information about the format can be found at
|
131
|
+
the {KCachegrind}[link:http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindCalltreeFormat] site.
|
132
|
+
|
133
|
+
== Printers
|
134
|
+
|
135
|
+
Reports are created by printers. Supported printers include:
|
136
|
+
|
115
137
|
* RubyProf::FlatPrinter - Creates a flat report in text format
|
116
138
|
* RubyProf::GraphPrinter - Creates a call graph report in text format
|
117
139
|
* RubyProf::GraphHtmlPrinter - Creates a call graph report in HTML (separate files per thread)
|
140
|
+
* RubyProf::CallTreePrinter - Creates a call tree report compatible with KCachegrind.
|
118
141
|
|
119
142
|
To use a printer:
|
120
143
|
|
@@ -124,14 +147,20 @@ To use a printer:
|
|
124
147
|
|
125
148
|
The first parameter is any writable IO object such as STDOUT or a file.
|
126
149
|
The second parameter, which has a default value of 0, specifies
|
127
|
-
the minimum percentage a method must take to be printed.
|
150
|
+
the minimum percentage a method must take to be printed. Percentages
|
151
|
+
should be specified as integers in the range 0 to 100. For more
|
128
152
|
information please see the documentation for the different printers.
|
129
153
|
|
130
154
|
|
131
|
-
==
|
155
|
+
== Measurements
|
156
|
+
|
157
|
+
Depending on the mode and platform, ruby-prof can measure various
|
158
|
+
aspects of a Ruby program. Supported measurements include:
|
132
159
|
|
133
|
-
|
134
|
-
|
160
|
+
* process time
|
161
|
+
* wall time
|
162
|
+
* cpu time
|
163
|
+
* object allocations
|
135
164
|
|
136
165
|
Process time measures the time used by a process between any two moments.
|
137
166
|
It is unaffected by other processes concurrently running
|
@@ -147,21 +176,29 @@ CPU time uses the CPU clock counter to measure time. The returned
|
|
147
176
|
values are dependent on the correctly setting the CPU's frequency.
|
148
177
|
This mode is only supported on Pentium or PowerPC platforms.
|
149
178
|
|
150
|
-
|
179
|
+
Object allocations report which methods allocate objects in a running
|
180
|
+
program. This support was generously donated by Sylvain Joyeux.
|
181
|
+
This mode requires a patched Ruby interpreter. For more
|
182
|
+
information, see:
|
183
|
+
http://rubyforge.org/tracker/index.php?func=detail&aid=11497&group_id=426&atid=1700
|
184
|
+
|
185
|
+
To set the measurement:
|
151
186
|
|
152
|
-
|
153
|
-
|
154
|
-
|
187
|
+
* RubyProf.measure_mode = RubyProf::PROCESS_TIME
|
188
|
+
* RubyProf.measure_mode = RubyProf::WALL_TIME
|
189
|
+
* RubyProf.measure_mode = RubyProf::CPU_TIME
|
190
|
+
* RubyProf.measure_mode = RubyProf::ALLOCATIONS
|
155
191
|
|
156
|
-
|
192
|
+
The default value is RubyProf::PROCESS_TIME.
|
157
193
|
|
158
|
-
You may also specify the
|
194
|
+
You may also specify the measure_mode by using the RUBY_PROF_MEASURE_MODE
|
159
195
|
environment variable:
|
160
196
|
|
161
|
-
|
162
|
-
export
|
163
|
-
|
164
|
-
|
197
|
+
* export RUBY_PROF_MEASURE_MODE=process
|
198
|
+
* export RUBY_PROF_MEASURE_MODE=wall
|
199
|
+
* export RUBY_PROF_MEASURE_MODE=cpu
|
200
|
+
* export RUBY_PROF_MEASURE_MODE=allocations
|
201
|
+
|
165
202
|
Note that these values have changed since ruby-prof-0.3.0.
|
166
203
|
|
167
204
|
On Linux, process time is measured using the clock method provided
|
@@ -212,7 +249,10 @@ high end its can around 80%.
|
|
212
249
|
|
213
250
|
== Windows Binary
|
214
251
|
|
215
|
-
The Windows binary is built with the latest version of MinGW.
|
252
|
+
The Windows binary is built with the latest version of MinGW. The source
|
253
|
+
repository also includes a Microsoft VC++ 2005 solution. If you wish to run
|
254
|
+
a debug version of ruby-prof on Windows, then it is highly recommended
|
255
|
+
you use VC++.
|
216
256
|
|
217
257
|
|
218
258
|
== License
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/rdoctask'
|
|
5
5
|
SO_NAME = "ruby_prof.so"
|
6
6
|
|
7
7
|
# ------- Default Package ----------
|
8
|
-
RUBY_PROF_VERSION = "0.
|
8
|
+
RUBY_PROF_VERSION = "0.5.0"
|
9
9
|
|
10
10
|
FILES = FileList[
|
11
11
|
'Rakefile',
|
@@ -49,8 +49,8 @@ EOF
|
|
49
49
|
spec.test_files = Dir["test/test_*.rb"]
|
50
50
|
|
51
51
|
|
52
|
-
spec.required_ruby_version = '>= 1.8.
|
53
|
-
|
52
|
+
spec.required_ruby_version = '>= 1.8.4'
|
53
|
+
spec.date = DateTime.now
|
54
54
|
spec.rubyforge_project = 'ruby-prof'
|
55
55
|
|
56
56
|
# rdoc
|
@@ -61,12 +61,12 @@ EOF
|
|
61
61
|
# Make the readme file the start page for the generated html
|
62
62
|
spec.rdoc_options << '--main' << 'README'
|
63
63
|
spec.extra_rdoc_files = ['bin/ruby-prof',
|
64
|
+
'ext/ruby_prof.c',
|
64
65
|
'examples/flat.txt',
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
'LICENSE']
|
66
|
+
'examples/graph.txt',
|
67
|
+
'examples/graph.html',
|
68
|
+
'README',
|
69
|
+
'LICENSE']
|
70
70
|
|
71
71
|
end
|
72
72
|
|
@@ -74,7 +74,7 @@ end
|
|
74
74
|
# Rake task to build the default package
|
75
75
|
Rake::GemPackageTask.new(default_spec) do |pkg|
|
76
76
|
pkg.need_tar = true
|
77
|
-
pkg.
|
77
|
+
pkg.need_zip = true
|
78
78
|
end
|
79
79
|
|
80
80
|
|
@@ -89,21 +89,23 @@ win_spec.files += ["lib/#{SO_NAME}"]
|
|
89
89
|
|
90
90
|
desc "Create Windows Gem"
|
91
91
|
task :create_win32_gem do
|
92
|
-
# Copy the win32 extension
|
92
|
+
# Copy the win32 extension built by MingW - easier to install
|
93
|
+
# since there are no dependencies of msvcr80.dll
|
93
94
|
current_dir = File.expand_path(File.dirname(__FILE__))
|
94
|
-
source = File.join(current_dir, "
|
95
|
+
source = File.join(current_dir, "mingw", SO_NAME)
|
95
96
|
target = File.join(current_dir, "lib", SO_NAME)
|
96
97
|
cp(source, target)
|
97
98
|
|
98
99
|
# Create the gem, then move it to pkg
|
99
|
-
|
100
|
-
|
100
|
+
Gem::Builder.new(win_spec).build
|
101
|
+
gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
|
101
102
|
mv(gem_file, "pkg/#{gem_file}")
|
102
103
|
|
103
|
-
# Remove win extension
|
104
|
-
|
104
|
+
# Remove win extension from top level directory
|
105
|
+
rm(target)
|
105
106
|
end
|
106
107
|
|
108
|
+
|
107
109
|
task :package => :create_win32_gem
|
108
110
|
|
109
111
|
# --------- RDoc Documentation ------
|
@@ -115,27 +117,26 @@ Rake::RDocTask.new("rdoc") do |rdoc|
|
|
115
117
|
rdoc.options << "--inline-source" << "--line-numbers"
|
116
118
|
# Make the readme file the start page for the generated html
|
117
119
|
rdoc.options << '--main' << 'README'
|
118
|
-
rdoc.rdoc_files.include('bin/**/*',
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
'lib/**/*.rb',
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
end
|
128
|
-
|
120
|
+
rdoc.rdoc_files.include('bin/**/*',
|
121
|
+
'doc/*.rdoc',
|
122
|
+
'examples/flat.txt',
|
123
|
+
'examples/graph.txt',
|
124
|
+
'examples/graph.html',
|
125
|
+
'lib/**/*.rb',
|
126
|
+
'ext/**/ruby_prof.c',
|
127
|
+
'README',
|
128
|
+
'LICENSE')
|
129
|
+
end
|
129
130
|
|
130
131
|
|
131
132
|
# --------- Publish to RubyForge ----------------
|
132
133
|
desc "Publish ruby-prof to RubyForge."
|
133
134
|
task :publish do
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
135
|
+
require 'rake/contrib/sshpublisher'
|
136
|
+
|
137
|
+
# Get ruby-prof path
|
138
|
+
ruby_prof_path = File.expand_path(File.dirname(__FILE__))
|
138
139
|
|
139
|
-
|
140
|
-
|
140
|
+
publisher = Rake::SshDirPublisher.new("cfis@rubyforge.org",
|
141
|
+
"/var/www/gforge-projects/ruby-prof", ruby_prof_path)
|
141
142
|
end
|
data/bin/ruby-prof
CHANGED
@@ -13,12 +13,16 @@
|
|
13
13
|
# flat - Prints a flat profile as text (default).
|
14
14
|
# graph - Prints a graph profile as text.
|
15
15
|
# graph_html - Prints a graph profile as html.
|
16
|
+
# call_tree - format for KCacheGrind
|
16
17
|
# -f, --file=path Output results to a file instead of standard out.
|
17
|
-
# -
|
18
|
+
# -m, --measure-mode=measure_mode Select a measurement mode:
|
18
19
|
# process - Use process time (default).
|
19
20
|
# wall - Use wall time.
|
20
21
|
# cpu - Use the CPU clock counter
|
21
22
|
# (only supported on Pentium and PowerPCs).
|
23
|
+
# allocations - Tracks object allocations
|
24
|
+
# (requires a patched Ruby interpreter).
|
25
|
+
# --replace-progname Replace $0 when loading the .rb files.
|
22
26
|
# -h, --help Show help message
|
23
27
|
# --version Show version
|
24
28
|
#
|
@@ -26,85 +30,95 @@
|
|
26
30
|
# See also: {flat profiles}[link:files/examples/flat_txt.html], {graph profiles}[link:files/examples/graph_txt.html], {html graph profiles}[link:files/examples/graph_html.html]
|
27
31
|
#
|
28
32
|
|
29
|
-
|
30
33
|
require 'ostruct'
|
31
34
|
require 'optparse'
|
32
35
|
require 'ruby-prof'
|
33
36
|
|
34
37
|
options = OpenStruct.new
|
35
|
-
options.
|
38
|
+
options.measure_mode = RubyProf::PROCESS_TIME
|
36
39
|
options.printer = RubyProf::FlatPrinter
|
37
40
|
options.min_percent = 0
|
38
41
|
options.file = nil
|
42
|
+
options.replace_prog_name = false
|
39
43
|
|
40
44
|
opts = OptionParser.new do |opts|
|
41
|
-
|
42
|
-
|
45
|
+
opts.banner = "ruby_prof #{RubyProf::VERSION}\n" +
|
46
|
+
"Usage: ruby_prof [options] <script.rb> [--extra-options-for-script]"
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
48
|
+
opts.separator ""
|
49
|
+
opts.separator "Options:"
|
50
|
+
|
51
|
+
|
52
|
+
opts.on('-p printer', '--printer=printer', [:flat, :graph, :graph_html, :call_tree],
|
53
|
+
'Select a printer:',
|
54
|
+
' flat - Prints a flat profile as text (default).',
|
55
|
+
' graph - Prints a graph profile as text.',
|
56
|
+
' graph_html - Prints a graph profile as html.',
|
57
|
+
' call_tree - format for KCacheGrind' ) do |printer|
|
58
|
+
|
59
|
+
|
60
|
+
case printer
|
61
|
+
when :flat
|
62
|
+
options.printer = RubyProf::FlatPrinter
|
63
|
+
when :graph
|
64
|
+
options.printer = RubyProf::GraphPrinter
|
65
|
+
when :graph_html
|
66
|
+
options.printer = RubyProf::GraphHtmlPrinter
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on('-m min_percent', '--min_percent=min_percent', Float,
|
71
|
+
'The minimum percent a method must take before ',
|
72
|
+
' being included in output reports.',
|
73
|
+
' this option is not supported for call tree.') do |min_percent|
|
74
|
+
options.min_percent = min_percent
|
75
|
+
end
|
76
|
+
|
77
|
+
opts.on('-f path', '--file=path',
|
78
|
+
'Output results to a file instead of standard out.') do |file|
|
79
|
+
options.file = file
|
80
|
+
end
|
81
|
+
|
82
|
+
opts.on('-m measure_mode', '--measure-mode=measure_mode',
|
83
|
+
[:process, :wall, :cpu, :allocations],
|
84
|
+
'Select what ruby-prof should measure:',
|
85
|
+
' process - Process time (default).',
|
86
|
+
' wall - Wall time.',
|
87
|
+
' cpu - CPU time',
|
88
|
+
' (only supported on Pentium and PowerPCs).',
|
89
|
+
' allocations - O3bject allocations (required patched Ruby interpreter).') do |measure_mode|
|
90
|
+
|
91
|
+
case measure_mode
|
92
|
+
when :process
|
93
|
+
options.measure_mode = RubyProf::PROCESS_TIME
|
94
|
+
when :wall
|
95
|
+
options.measure_mode = RubyProf::WALL_TIME
|
96
|
+
when :cpu
|
97
|
+
options.measure_mode = RubyProf::CPU_TIME
|
98
|
+
when :allocations
|
99
|
+
options.measure_mode = RubyProf::ALLOCATIONS
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
opts.on("--replace-progname", "Replace $0 when loading the .rb files.") do
|
104
|
+
options.replace_prog_name = true
|
105
|
+
end
|
106
|
+
|
107
|
+
opts.on_tail("-h", "--help", "Show help message") do
|
108
|
+
puts opts
|
109
|
+
exit
|
110
|
+
end
|
111
|
+
opts.on_tail("-v", "--version", "Show version") do
|
112
|
+
puts "ruby_prof " + RubyProf::VERSION
|
113
|
+
exit
|
114
|
+
end
|
101
115
|
end
|
102
116
|
|
103
117
|
begin
|
104
|
-
|
118
|
+
opts.parse! ARGV
|
105
119
|
rescue OptionParser::InvalidOption, OptionParser::InvalidArgument,
|
106
120
|
OptionParser::MissingArgument => e
|
107
|
-
|
121
|
+
puts opts
|
108
122
|
puts
|
109
123
|
puts e.message
|
110
124
|
exit(-1)
|
@@ -112,9 +126,9 @@ end
|
|
112
126
|
|
113
127
|
# Make sure the user specified at least one file
|
114
128
|
if ARGV.length < 1
|
115
|
-
|
116
|
-
|
117
|
-
|
129
|
+
puts opts
|
130
|
+
puts ""
|
131
|
+
puts "Must specify a script to run"
|
118
132
|
exit(-1)
|
119
133
|
end
|
120
134
|
|
@@ -125,27 +139,30 @@ end
|
|
125
139
|
|
126
140
|
at_exit {
|
127
141
|
# Stop profiling
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
+
result = RubyProf.stop
|
143
|
+
|
144
|
+
# Create a printer
|
145
|
+
printer = options.printer.new(result)
|
146
|
+
|
147
|
+
# Get output
|
148
|
+
if options.file
|
149
|
+
File.open(options.file, 'w') do |file|
|
150
|
+
printer.print(file, options.min_percent)
|
151
|
+
end
|
152
|
+
else
|
153
|
+
# Print out results
|
154
|
+
printer.print(STDOUT, options.min_percent)
|
155
|
+
end
|
142
156
|
}
|
143
157
|
|
144
|
-
# Now set
|
145
|
-
RubyProf.
|
158
|
+
# Now set measure mode
|
159
|
+
RubyProf.measure_mode = options.measure_mode
|
146
160
|
|
147
161
|
# Get the script we will execute
|
148
162
|
script = ARGV.shift
|
163
|
+
if options.replace_prog_name
|
164
|
+
$0 = File.basename(File.expand_path(script))
|
165
|
+
end
|
149
166
|
|
150
167
|
# Start profiling
|
151
168
|
RubyProf.start
|