ruby-prof 0.4.1-mswin32 → 0.5.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/CHANGES +30 -0
  2. data/README +65 -25
  3. data/Rakefile +33 -32
  4. data/bin/ruby-prof +100 -83
  5. data/examples/graph.html +65 -69
  6. data/ext/measure_allocations.h +43 -0
  7. data/ext/measure_cpu_time.h +138 -0
  8. data/ext/measure_process_time.h +41 -0
  9. data/ext/measure_wall_time.h +42 -0
  10. data/ext/ruby_prof.c +737 -653
  11. data/lib/ruby-prof.rb +41 -38
  12. data/lib/ruby-prof/abstract_printer.rb +42 -0
  13. data/lib/ruby-prof/call_tree_printer.rb +69 -0
  14. data/lib/ruby-prof/flat_printer.rb +78 -75
  15. data/lib/ruby-prof/graph_html_printer.rb +241 -228
  16. data/lib/ruby-prof/graph_printer.rb +160 -141
  17. data/lib/ruby-prof/profile_test_case.rb +80 -0
  18. data/lib/ruby-prof/rails_plugin/ruby-prof/init.rb +6 -0
  19. data/lib/ruby-prof/rails_plugin/ruby-prof/lib/profiling.rb +52 -0
  20. data/lib/ruby-prof/task.rb +147 -0
  21. data/lib/ruby_prof.so +0 -0
  22. data/test/basic_test.rb +65 -35
  23. data/test/duplicate_names_test.rb +20 -24
  24. data/test/gc.log +5 -0
  25. data/test/measure_mode_test.rb +79 -0
  26. data/test/module_test.rb +31 -18
  27. data/test/no_method_class_test.rb +14 -0
  28. data/test/prime1.rb +17 -0
  29. data/test/prime2.rb +26 -0
  30. data/test/prime3.rb +17 -0
  31. data/test/prime_test.rb +10 -10
  32. data/test/printers_test.rb +14 -12
  33. data/test/profile_unit_test.rb +24 -0
  34. data/test/recursive_test.rb +105 -17
  35. data/test/singleton_test.rb +38 -0
  36. data/test/start_test.rb +24 -0
  37. data/test/test_helper.rb +33 -29
  38. data/test/test_suite.rb +10 -2
  39. data/test/thread_test.rb +123 -17
  40. data/test/timing_test.rb +70 -29
  41. metadata +28 -30
  42. data/doc/created.rid +0 -1
  43. data/doc/files/LICENSE.html +0 -0
  44. data/doc/files/README.html +0 -376
  45. data/doc/files/bin/ruby-prof.html +0 -143
  46. data/doc/files/examples/flat_txt.html +0 -179
  47. data/doc/files/examples/graph_html.html +0 -948
  48. data/doc/files/examples/graph_txt.html +0 -297
  49. data/doc/files/ext/ruby_prof_c.html +0 -101
  50. data/doc/files/lib/ruby-prof/flat_printer_rb.html +0 -101
  51. data/doc/files/lib/ruby-prof/graph_html_printer_rb.html +0 -108
  52. data/doc/files/lib/ruby-prof/graph_printer_rb.html +0 -101
  53. data/doc/files/lib/ruby-prof/profiletask_rb.html +0 -109
  54. data/doc/files/lib/ruby-prof_rb.html +0 -111
  55. data/doc/files/lib/unprof_rb.html +0 -108
  56. data/doc/rdoc-style.css +0 -208
  57. data/lib/ruby-prof/profiletask.rb +0 -150
  58. 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.2 or higher.
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 flat profile and graph profile reports.
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. Graph profiles can be generated
108
- in text and html. Since the html is cross-referenced it is
109
- easier to work with. An example text graph profile
110
- is located at {examples/graph.txt}[link:files/examples/graph_txt.html] while
111
- an example html graph file is located at
112
- {examples/graph.html}[link:files/examples/graph_html.html].
113
-
114
- Reports are created by printers. The current printers include:
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. For more
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
- == Timing Data
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
- Depending on the mode and platform, ruby-prof can measure time in
134
- three ways - process time, wall time and cpu time.
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
- To set the clock_mode:
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
- RubyProf.clock_mode = RubyProf::PROCESS_TIME
153
- RubyProf.clock_mode = RubyProf::WALL_TIME
154
- RubyProf.clock_mode = RubyProf::CPU_TIME
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
- This default value is PROCESS_TIME.
192
+ The default value is RubyProf::PROCESS_TIME.
157
193
 
158
- You may also specify the clock_mode by using the RUBY_PROF_CLOCK_MODE
194
+ You may also specify the measure_mode by using the RUBY_PROF_MEASURE_MODE
159
195
  environment variable:
160
196
 
161
- export RUBY_PROF_CLOCK_MODE=process
162
- export RUBY_PROF_CLOCK_MODE=wall
163
- export RUBY_PROF_CLOCK_MODE=cpu
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.4.1"
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.2'
53
- spec.date = DateTime.now
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
- 'examples/graph.txt',
66
- 'examples/graph.html',
67
- 'ext/ruby_prof.c',
68
- 'README',
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.need_tar = true
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 the top level directory
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, "ext", "win32", SO_NAME)
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
- Gem::Builder.new(win_spec).build
100
- gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
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 fro top level directory
104
- rm(target)
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
- 'doc/*.rdoc',
120
- 'examples/flat.txt',
121
- 'examples/graph.txt',
122
- 'examples/graph.html',
123
- 'lib/**/*.rb',
124
- 'ext/**/ruby_prof.c',
125
- 'README',
126
- 'LICENSE')
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
- require 'rake/contrib/sshpublisher'
135
-
136
- # Get ruby-prof path
137
- ruby_prof_path = File.expand_path(File.dirname(__FILE__))
135
+ require 'rake/contrib/sshpublisher'
136
+
137
+ # Get ruby-prof path
138
+ ruby_prof_path = File.expand_path(File.dirname(__FILE__))
138
139
 
139
- publisher = Rake::SshDirPublisher.new("cfis@rubyforge.org",
140
- "/var/www/gforge-projects/ruby-prof", ruby_prof_path)
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
- # -c, --clock-mode=clock_mode Select a clock mode:
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.clock_mode = RubyProf::PROCESS_TIME
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
- opts.banner = "ruby_prof #{RubyProf::VERSION}\n" +
42
- "Usage: ruby_prof [options] <script.rb> [--extra-options-for-script]"
45
+ opts.banner = "ruby_prof #{RubyProf::VERSION}\n" +
46
+ "Usage: ruby_prof [options] <script.rb> [--extra-options-for-script]"
43
47
 
44
- opts.separator ""
45
- opts.separator "Options:"
46
-
47
-
48
- opts.on('-p printer', '--printer=printer', [:flat, :graph, :graph_html],
49
- 'Select a printer:',
50
- ' flat - Prints a flat profile as text (default).',
51
- ' graph - Prints a graph profile as text.',
52
- ' graph_html - Prints a graph profile as html.') do |printer|
53
-
54
- case printer
55
- when :flat
56
- options.printer = RubyProf::FlatPrinter
57
- when :graph
58
- options.printer = RubyProf::GraphPrinter
59
- when :graph_html
60
- options.printer = RubyProf::GraphHtmlPrinter
61
- end
62
- end
63
-
64
- opts.on('-m min_percent', '--min_percent=min_percent', Float,
65
- 'The minimum percent a method must take before ',
66
- ' being included in output reports') do |min_percent|
67
- options.min_percent = min_percent
68
- end
69
-
70
- opts.on('-f path', '--file=path',
71
- 'Output results to a file instead of standard out.') do |file|
72
- options.file = file
73
- end
74
-
75
- opts.on('-c clock_mode', '--clock-mode=clock_mode',
76
- [:process, :wall, :cpu],
77
- 'Select a clock mode:',
78
- ' process - Use process time (default).',
79
- ' wall - Use wall time.',
80
- ' cpu - Use the CPU clock counter',
81
- ' (only supported on Pentium and PowerPCs).') do |clock_mode|
82
-
83
- case
84
- when :process
85
- options.clock_mode = RubyProf::PROCESS_TIME
86
- when :wall
87
- options.clock_mode = RubyProf::WALL_TIME
88
- when :cpu
89
- options.clock_mode = RubyProf::CPU_TIME
90
- end
91
- end
92
-
93
- opts.on_tail("-h", "--help", "Show help message") do
94
- puts opts
95
- exit
96
- end
97
- opts.on_tail("-v", "--version", "Show version") do
98
- puts "ruby_prof " + RubyProf::VERSION
99
- exit
100
- end
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
- opts.parse! ARGV
118
+ opts.parse! ARGV
105
119
  rescue OptionParser::InvalidOption, OptionParser::InvalidArgument,
106
120
  OptionParser::MissingArgument => e
107
- puts opts
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
- puts opts
116
- puts ""
117
- puts "Must specify a script to run"
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
- result = RubyProf.stop
129
-
130
- # Create a printer
131
- printer = options.printer.new(result)
132
-
133
- # Get output
134
- if options.file
135
- File.open(options.file, 'w') do |file|
136
- printer.print(file, options.min_percent)
137
- end
138
- else
139
- # Print out results
140
- printer.print(STDOUT, options.min_percent)
141
- end
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 clock mode
145
- RubyProf.clock_mode = options.clock_mode
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