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/CHANGES ADDED
@@ -0,0 +1,17 @@
1
+
2
+ 0.4.0 (2006-06-16)
3
+ ========================
4
+ Features
5
+ --------
6
+ * added support for call graphs
7
+ * added support for printers. Currently there is a FlatPrinter,
8
+ GraphPrinter and GraphHtmlPrinter.
9
+ * added support for recursive methods
10
+ * added Windows support
11
+ * now packaged as a RubyGem
12
+
13
+ Fixes
14
+ -------
15
+ * Fixes bug where RubyProf would crash depending on the
16
+ way it was invoked - for example, it did not run when
17
+ used with Arachno Ruby's customized version of Ruby.
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (C) 2005 Shugo Maeda <shugo@ruby-lang.org>
2
+ All rights reserved.
3
+ *
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions
6
+ are met:
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ *
13
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
17
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
+ SUCH DAMAGE.
data/README ADDED
@@ -0,0 +1,220 @@
1
+ = ruby-prof
2
+
3
+ == Overview
4
+
5
+ ruby-prof is a fast code profiler for Ruby. Its features include:
6
+
7
+ * Speed - it is a C extension and therefore many times faster than the standard Ruby profiler.
8
+ * Flat Profiles - similar to the reports generated by the standard Ruby profiler
9
+ * Graph profiles - similar to GProf, these show how long a method runs, which methods call it and which methods it calls.
10
+ * Threads - supports profiling multiple threads simultaneously
11
+ * Recursive calls - supports profiling recursive method calls
12
+ * Reports - can generate both text and cross-referenced html reports
13
+ * Output - can output to standard out or to a file
14
+
15
+
16
+ == Requirements
17
+
18
+ ruby-prof requires Ruby 1.8.2 or higher.
19
+
20
+ If you are running Linux or Unix you'll need a C compiler so the extension
21
+ can be compiled when it is installed.
22
+
23
+ If you are running Windows, then install the Windows specific RubyGem which
24
+ includes an already built extension.
25
+
26
+
27
+ == Install
28
+
29
+ ruby-prof is provided as a RubyGem. To install:
30
+
31
+ <tt>gem install ruby-prof</tt>
32
+
33
+ If you are running Windows, make sure to install the Win32 RubyGem which
34
+ includes a pre-built binary.
35
+
36
+ == Usage
37
+
38
+ There are three ways of running ruby-prof.
39
+
40
+ === ruby-prof executable
41
+
42
+ The first is to use ruby-prof to run the Ruby program
43
+ you want to profile. For more information refer to
44
+ the ruby-prof documentation[link:files/bin/ruby-prof.html].
45
+
46
+ === ruby-prof API
47
+
48
+ The second way is to use the ruby-prof API to profile
49
+ particular segments of code.
50
+
51
+ require 'ruby-prof'
52
+
53
+ # Profile the code
54
+ RubyProf.start
55
+ ...
56
+ [code to profile]
57
+ ...
58
+ result = RubyProf.end
59
+
60
+ # Print a flat profile to text
61
+ printer = RubyProf::TextPrinter.new(result)
62
+ printer.print(STDOUT, 0)
63
+
64
+ Alternatively, you can use a block to tell ruby-prof what
65
+ to profile:
66
+
67
+ require 'ruby-prof'
68
+
69
+ # Profile the code
70
+ result = RubyProf.profile do
71
+ ...
72
+ [code to profile]
73
+ ...
74
+ end
75
+
76
+ # Print a graph profile to text
77
+ printer = RubyProf::GraphPrinter.new(result)
78
+ printer.print(STDOUT, 0)
79
+
80
+
81
+ === require unprof
82
+
83
+ The third way of using ruby-prof is by requiring unprof.rb:
84
+
85
+ require 'unprof'
86
+
87
+ This will start profiling immediately and will output the results
88
+ using a flat profile report.
89
+
90
+ This method is provided for backwards compatibility. Using
91
+ {ruby-prof}[link:files/bin/ruby-prof.html] provides more flexibility.
92
+
93
+
94
+ == Reports
95
+
96
+ ruby-prof can generate flat profile and graph profile reports.
97
+
98
+ Flat profiles show the overall time spent in each method. They
99
+ are a good of quickly identifying which methods take the most time.
100
+ An example of a flat profile and an explanation can be found in
101
+ {examples/flat.txt}[link:files/examples/flat_txt.html].
102
+
103
+ Graph profiles also show the overall time spent in each method.
104
+ In addition, they also show which methods call the current
105
+ method and which methods its calls. Thus they are good for
106
+ 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:
115
+ * RubyProf::FlatPrinter - Creates a flat report in text format
116
+ * RubyProf::GraphPrinter - Creates a call graph report in text format
117
+ * RubyProf::GraphHtmlPrinter - Creates a call graph report in HTML (separate files per thread)
118
+
119
+ To use a printer:
120
+
121
+ result = RubyProf.end
122
+ printer = RubyProf::GraphPrinter.new(result)
123
+ printer.print(STDOUT, 0)
124
+
125
+ The first parameter is any writable IO object such as STDOUT or a file.
126
+ The second parameter, which has a default value of 0, specifies
127
+ the minimum percentage a method must take to be printed. For more
128
+ information please see the documentation for the different printers.
129
+
130
+
131
+ == Timing Data
132
+
133
+ Depending on the mode and platform, ruby-prof can measure time in
134
+ three ways - process time, wall time and cpu time.
135
+
136
+ Process time measures the time used by a process between any two moments.
137
+ It is unaffected by other processes concurrently running
138
+ on the system. Note that Windows does not support measuring process
139
+ times - therefore, all measurements on Windows use wall time.
140
+
141
+ Wall time measures the real-world time elapsed between any two moments.
142
+ If there are other processes concurrently running on the system
143
+ that use significant CPU or disk time during a profiling run
144
+ then the reported results will be too large.
145
+
146
+ CPU time uses the CPU clock counter to measure time. The returned
147
+ values are dependent on the correctly setting the CPU's frequency.
148
+ This mode is only supported on Pentium or PowerPC platforms.
149
+
150
+ To set the clock_mode:
151
+
152
+ RubyProf.clock_mode = RubyProf::PROCESS_TIME
153
+ RubyProf.clock_mode = RubyProf::WALL_TIME
154
+ RubyProf.clock_mode = RubyProf::CPU_TIME
155
+
156
+ This default value is PROCESS_TIME.
157
+
158
+ You may also specify the clock_mode by using the RUBY_PROF_CLOCK_MODE
159
+ environment variable:
160
+
161
+ export RUBY_PROF_CLOCK_MODE=process
162
+ export RUBY_PROF_CLOCK_MODE=wall
163
+ export RUBY_PROF_CLOCK_MODE=cpu
164
+
165
+ Note that these values have changed since ruby-prof-0.3.0.
166
+
167
+ On Linux, process time is measured using the clock method provided
168
+ by the C runtime library. Note that the clock method does not
169
+ report time spent in the kernel or child processes and therefore
170
+ does not measure time spent in methods such as Kernel.sleep method.
171
+ If you need to measure these values, then use wall time. Wall time
172
+ is measured using the gettimeofday kernel method.
173
+
174
+ On Windows, timings are always wall times. If you set the clock
175
+ mode to PROCESS_TIME, then timing are read using the clock method
176
+ provided by the C runtime library. Note though, these values are
177
+ wall times on Windows and not process times like on Linux.
178
+ Wall time is measured using the GetLocalTime API.
179
+
180
+ On both platforms, cpu time is measured using the RDTSC assembly
181
+ function provided by the Pentium and PowerPC platforms. CPU time
182
+ is dependent on the cpu's frequency. On Linux, ruby-prof attempts
183
+ to read this value from "/proc/cpuinfo." On Windows, you must
184
+ specify the clock frequency. This can be done using the
185
+ RUBY_PROF_CPU_FREQUENCY environment variable:
186
+
187
+ export RUBY_PROF_CPU_FREQUENCY=<value>
188
+
189
+ You can also directly set the cpu frequency by calling:
190
+
191
+ RubyProf.cpu_frequency = <value>
192
+
193
+
194
+ == Recursive Calls
195
+
196
+ Recursive calls occur when method A calls method A and cycles
197
+ occur when method A calls method B calls method C calls method A.
198
+ ruby-prof can detect recursive calls any cycle calls, but does not
199
+ currently report these in its output.
200
+
201
+ However, the self time values for recursive calls should always
202
+ be accurate. It is also believed that the total times are
203
+ accurate, but these should be carefully analyzed to verify their veracity.
204
+
205
+ == Performance
206
+
207
+ Significant effort has been put into reducing ruby-prof's overhead
208
+ as much as possible. Our tests show that the overhead associated
209
+ with profiling code varies considerably with the code being
210
+ profiled. On the low end overhead is around 10% while on the
211
+ high end its can around 80%.
212
+
213
+ == Windows Binary
214
+
215
+ The Windows binary is built with the latest version of MinGW.
216
+
217
+
218
+ == License
219
+
220
+ See LICENSE for license information.
data/Rakefile ADDED
@@ -0,0 +1,141 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rake/rdoctask'
4
+
5
+ SO_NAME = "ruby_prof.so"
6
+
7
+ # ------- Default Package ----------
8
+ RUBY_PROF_VERSION = "0.4.0"
9
+
10
+ FILES = FileList[
11
+ 'Rakefile',
12
+ 'README',
13
+ 'LICENSE',
14
+ 'CHANGES',
15
+ 'bin/*',
16
+ 'lib/**/*',
17
+ 'examples/*',
18
+ 'ext/*',
19
+ 'doc/**/*',
20
+ 'test/*'
21
+ ]
22
+
23
+ # Default GEM Specification
24
+ default_spec = Gem::Specification.new do |spec|
25
+ spec.name = "ruby-prof"
26
+
27
+ spec.homepage = "http://rubyforge.org/projects/ruby-prof/"
28
+ spec.summary = "Fast Ruby profiler"
29
+ spec.description = <<-EOF
30
+ ruby-prof is a fast code profiler for Ruby. It is a C extension and
31
+ therefore is many times faster than the standard Ruby profiler. It
32
+ supports both flat and graph profiles. For each method, graph profiles
33
+ show how long the method ran, which methods called it and which
34
+ methods it called. RubyProf generate both text and html and can output
35
+ it to standard out or to a file.
36
+ EOF
37
+
38
+ spec.version = RUBY_PROF_VERSION
39
+
40
+ spec.author = "Shugo Maeda and Charlie Savage"
41
+ spec.email = "shugo@ruby-lang.org and cfis@savagexi.com"
42
+ spec.platform = Gem::Platform::RUBY
43
+ spec.require_path = "lib"
44
+ spec.bindir = "bin"
45
+ spec.executables = ["ruby-prof"]
46
+ spec.extensions = ["ext/extconf.rb"]
47
+ spec.autorequire = "ruby-prof"
48
+ spec.files = FILES.to_a
49
+ spec.test_files = Dir["test/test_*.rb"]
50
+
51
+
52
+ spec.required_ruby_version = '>= 1.8.2'
53
+ spec.date = DateTime.now
54
+ spec.rubyforge_project = 'ruby-prof'
55
+
56
+ # rdoc
57
+ spec.has_rdoc = true
58
+ spec.rdoc_options << "--title" << "ruby-prof"
59
+ # Show source inline with line numbers
60
+ spec.rdoc_options << "--inline-source" << "--line-numbers"
61
+ # Make the readme file the start page for the generated html
62
+ spec.rdoc_options << '--main' << 'README'
63
+ spec.extra_rdoc_files = ['bin/ruby-prof',
64
+ 'examples/flat.txt',
65
+ 'examples/graph.txt',
66
+ 'examples/graph.html',
67
+ 'ext/ruby_prof.c',
68
+ 'README',
69
+ 'LICENSE']
70
+
71
+ end
72
+
73
+
74
+ # Rake task to build the default package
75
+ Rake::GemPackageTask.new(default_spec) do |pkg|
76
+ pkg.need_zip = false
77
+ pkg.need_tar = false
78
+ end
79
+
80
+
81
+ # ------- Windows Package ----------
82
+
83
+ # Windows specification
84
+ win_spec = default_spec.clone
85
+ win_spec.extensions = []
86
+ win_spec.platform = Gem::Platform::WIN32
87
+ win_spec.files += ["lib/#{SO_NAME}"]
88
+
89
+
90
+ desc "Create Windows Gem"
91
+ task :create_win32_gem do
92
+ # Copy the win32 extension the top level directory
93
+ current_dir = File.expand_path(File.dirname(__FILE__))
94
+ source = File.join(current_dir, "ext", "win32", SO_NAME)
95
+ target = File.join(current_dir, "lib", SO_NAME)
96
+ cp(source, target)
97
+
98
+ # 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"
101
+ mv(gem_file, "pkg/#{gem_file}")
102
+
103
+ # Remove win extension fro top level directory
104
+ rm(target)
105
+ end
106
+
107
+ task :package => :create_win32_gem
108
+
109
+ # --------- RDoc Documentation ------
110
+ desc "Generate rdoc documentation"
111
+ Rake::RDocTask.new("rdoc") do |rdoc|
112
+ rdoc.rdoc_dir = 'doc'
113
+ rdoc.title = "ruby-prof"
114
+ # Show source inline with line numbers
115
+ rdoc.options << "--inline-source" << "--line-numbers"
116
+ # Make the readme file the start page for the generated html
117
+ 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
+
129
+
130
+
131
+ # --------- Publish to RubyForge ----------------
132
+ desc "Publish ruby-prof to RubyForge."
133
+ task :publish do
134
+ require 'rake/contrib/sshpublisher'
135
+
136
+ # Get ruby-prof path
137
+ ruby_prof_path = File.expand_path(File.dirname(__FILE__))
138
+
139
+ publisher = Rake::SshDirPublisher.new("cfis@rubyforge.org",
140
+ "/var/www/gforge-projects/ruby-prof", ruby_prof_path)
141
+ end
data/bin/ruby-prof ADDED
@@ -0,0 +1,154 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # == Synopsis
4
+ #
5
+ # Profiles a Ruby program.
6
+ #
7
+ # == Usage
8
+ #
9
+ # ruby_prof [options] <script.rb> [options-for-script]
10
+ #
11
+ # Options:
12
+ # -p, --printer=printer Select a printer:
13
+ # flat - Prints a flat profile as text (default).
14
+ # graph - Prints a graph profile as text.
15
+ # graph_html - Prints a graph profile as html.
16
+ # -f, --file=path Output results to a file instead of standard out.
17
+ # -c, --clock-mode=clock_mode Select a clock mode:
18
+ # process - Use process time (default).
19
+ # wall - Use wall time.
20
+ # cpu - Use the CPU clock counter
21
+ # (only supported on Pentium and PowerPCs).
22
+ # -h, --help Show help message
23
+ # --version Show version
24
+ #
25
+ #
26
+ # 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
+ #
28
+
29
+
30
+ require 'ostruct'
31
+ require 'optparse'
32
+ require 'ruby-prof'
33
+
34
+ options = OpenStruct.new
35
+ options.clock_mode = RubyProf::PROCESS_TIME
36
+ options.printer = RubyProf::FlatPrinter
37
+ options.min_percent = 0
38
+ options.file = nil
39
+
40
+ opts = OptionParser.new do |opts|
41
+ opts.banner = "ruby_prof #{RubyProf::VERSION}\n" +
42
+ "Usage: ruby_prof [options] <script.rb> [--extra-options-for-script]"
43
+
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
101
+ end
102
+
103
+ begin
104
+ opts.parse! ARGV
105
+ rescue OptionParser::InvalidOption, OptionParser::InvalidArgument,
106
+ OptionParser::MissingArgument => e
107
+ puts opts
108
+ puts
109
+ puts e.message
110
+ exit(-1)
111
+ end
112
+
113
+ # Make sure the user specified at least one file
114
+ if ARGV.length < 1
115
+ puts opts
116
+ puts ""
117
+ puts "Must specify a script to run"
118
+ exit(-1)
119
+ end
120
+
121
+
122
+ # Install at_exit handler. It is important that we do this
123
+ # before loading the scripts so our at_exit handler run
124
+ # *after* any other one that will be installed.
125
+
126
+ at_exit {
127
+ # 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
+ }
143
+
144
+ # Now set clock mode
145
+ RubyProf.clock_mode = options.clock_mode
146
+
147
+ # Get the script we will execute
148
+ script = ARGV.shift
149
+
150
+ # Start profiling
151
+ RubyProf.start
152
+
153
+ # Load the script
154
+ load script