ruby-prof 0.8.1-x86-mingw32 → 0.11.0.rc1-x86-mingw32
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 +89 -13
- data/LICENSE +4 -3
- data/{README → README.rdoc} +155 -162
- data/Rakefile +50 -123
- data/bin/ruby-prof +86 -47
- data/examples/empty.png +0 -0
- data/examples/graph.dot +106 -0
- data/examples/graph.png +0 -0
- data/examples/minus.png +0 -0
- data/examples/multi.flat.txt +23 -0
- data/examples/multi.graph.html +906 -0
- data/examples/multi.grind.dat +194 -0
- data/examples/multi.stack.html +573 -0
- data/examples/plus.png +0 -0
- data/examples/stack.html +573 -0
- data/ext/ruby_prof/extconf.rb +53 -0
- 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 +332 -1377
- data/ext/ruby_prof/ruby_prof.h +54 -188
- 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 +32 -18
- data/lib/ruby-prof/abstract_printer.rb +15 -5
- data/lib/ruby-prof/aggregate_call_info.rb +11 -3
- data/lib/ruby-prof/call_info.rb +68 -1
- data/lib/ruby-prof/call_stack_printer.rb +775 -0
- data/lib/ruby-prof/call_tree_printer.rb +17 -9
- data/lib/ruby-prof/compatibility.rb +134 -0
- data/lib/ruby-prof/dot_printer.rb +152 -0
- data/lib/ruby-prof/empty.png +0 -0
- data/lib/ruby-prof/flat_printer.rb +23 -24
- data/lib/ruby-prof/flat_printer_with_line_numbers.rb +17 -21
- data/lib/ruby-prof/graph_html_printer.rb +69 -39
- data/lib/ruby-prof/graph_printer.rb +35 -35
- data/lib/ruby-prof/method_info.rb +26 -4
- data/lib/ruby-prof/minus.png +0 -0
- data/lib/ruby-prof/multi_printer.rb +56 -0
- data/lib/ruby-prof/plus.png +0 -0
- data/lib/ruby-prof/profile.rb +72 -0
- data/lib/ruby-prof/rack.rb +31 -0
- data/lib/ruby-prof/symbol_to_proc.rb +3 -1
- data/lib/ruby-prof/task.rb +20 -19
- data/lib/ruby-prof/test.rb +5 -3
- 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 +29 -14
- data/test/basic_test.rb +3 -251
- data/test/bug_test.rb +6 -0
- data/test/duplicate_names_test.rb +4 -4
- data/test/dynamic_method_test.rb +61 -0
- data/test/enumerable_test.rb +4 -4
- data/test/exceptions_test.rb +6 -5
- data/test/exclude_threads_test.rb +47 -47
- data/test/exec_test.rb +5 -5
- data/test/line_number_test.rb +16 -16
- 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 +74 -0
- data/test/module_test.rb +12 -21
- data/test/multi_printer_test.rb +81 -0
- data/test/no_method_class_test.rb +5 -3
- data/test/prime.rb +7 -10
- data/test/prime_test.rb +3 -3
- data/test/printers_test.rb +180 -54
- data/test/recursive_test.rb +34 -72
- data/test/singleton_test.rb +5 -4
- data/test/stack_printer_test.rb +73 -0
- data/test/stack_test.rb +7 -7
- data/test/start_stop_test.rb +23 -6
- data/test/test_helper.rb +81 -0
- data/test/test_suite.rb +35 -21
- data/test/thread_test.rb +40 -39
- data/test/unique_call_path_test.rb +6 -6
- metadata +106 -51
- data/ext/ruby_prof/measure_allocations.h +0 -58
- 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 -52
- 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 -121
- data/test/ruby-prof-bin +0 -20
data/Rakefile
CHANGED
@@ -1,99 +1,67 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
'
|
32
|
-
'test/*'
|
33
|
-
]
|
34
|
-
|
35
|
-
# Default GEM Specification
|
36
|
-
default_spec = Gem::Specification.new do |spec|
|
37
|
-
spec.name = "ruby-prof"
|
38
|
-
|
39
|
-
spec.homepage = "http://rubyforge.org/projects/ruby-prof/"
|
40
|
-
spec.summary = "Fast Ruby profiler"
|
41
|
-
spec.description = <<-EOF
|
42
|
-
ruby-prof is a fast code profiler for Ruby. It is a C extension and
|
43
|
-
therefore is many times faster than the standard Ruby profiler. It
|
44
|
-
supports both flat and graph profiles. For each method, graph profiles
|
45
|
-
show how long the method ran, which methods called it and which
|
46
|
-
methods it called. RubyProf generate both text and html and can output
|
47
|
-
it to standard out or to a file.
|
48
|
-
EOF
|
49
|
-
|
50
|
-
spec.version = RUBY_PROF_VERSION
|
51
|
-
|
52
|
-
spec.author = "Shugo Maeda, Charlie Savage, Roger Pack"
|
53
|
-
spec.email = "shugo@ruby-lang.org, cfis@savagexi.com, rogerdpack@gmail.com"
|
54
|
-
spec.platform = Gem::Platform::RUBY
|
55
|
-
spec.require_path = "lib"
|
56
|
-
spec.bindir = "bin"
|
57
|
-
spec.executables = ["ruby-prof"]
|
58
|
-
spec.extensions = ["ext/ruby_prof/extconf.rb"]
|
59
|
-
spec.files = FILES.to_a
|
60
|
-
spec.test_files = Dir["test/test_*.rb"]
|
61
|
-
spec.required_ruby_version = '>= 1.8.4'
|
62
|
-
spec.date = DateTime.now
|
63
|
-
spec.rubyforge_project = 'ruby-prof'
|
64
|
-
spec.add_development_dependency 'os'
|
65
|
-
spec.add_development_dependency 'rake-compiler'
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
require 'rake/extensiontask'
|
70
|
-
|
71
|
-
desc 'build native .gem files -- use like native_gems clobber cross native gem RUBY_CC_VERSION=1.8.6:1.9.1--for non native use native_gems clobber && clean gem'
|
72
|
-
task :native_gems do
|
73
|
-
Rake::ExtensionTask.new('ruby_prof', default_spec) do |ext|
|
74
|
-
ext.cross_compile = true
|
75
|
-
ext.cross_platform = ['x86-mswin32', 'i386-mingw32']
|
76
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "rubygems/package_task"
|
4
|
+
require "rake/extensiontask"
|
5
|
+
require "rake/testtask"
|
6
|
+
require "rdoc/task"
|
7
|
+
require "date"
|
8
|
+
|
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>)
|
19
|
+
|
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']
|
77
32
|
end
|
78
33
|
|
79
34
|
# Rake task to build the default package
|
80
|
-
|
35
|
+
Gem::PackageTask.new(default_spec) do |pkg|
|
81
36
|
pkg.need_tar = true
|
82
|
-
#pkg.need_zip = true
|
83
37
|
end
|
84
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
|
85
46
|
|
47
|
+
# Unset extensions
|
48
|
+
win_spec.extensions = nil
|
86
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
|
87
55
|
|
88
56
|
# --------- RDoc Documentation ------
|
89
57
|
desc "Generate rdoc documentation"
|
90
|
-
|
58
|
+
RDoc::Task.new("rdoc") do |rdoc|
|
91
59
|
rdoc.rdoc_dir = 'doc'
|
92
60
|
rdoc.title = "ruby-prof"
|
93
61
|
# Show source inline with line numbers
|
94
62
|
rdoc.options << "--inline-source" << "--line-numbers"
|
95
63
|
# Make the readme file the start page for the generated html
|
96
|
-
rdoc.options << '--main' << 'README'
|
64
|
+
rdoc.options << '--main' << 'README.rdoc'
|
97
65
|
rdoc.rdoc_files.include('bin/**/*',
|
98
66
|
'doc/*.rdoc',
|
99
67
|
'examples/flat.txt',
|
@@ -103,7 +71,7 @@ Rake::RDocTask.new("rdoc") do |rdoc|
|
|
103
71
|
'ext/ruby_prof/ruby_prof.c',
|
104
72
|
'ext/ruby_prof/version.h',
|
105
73
|
'ext/ruby_prof/measure_*.h',
|
106
|
-
'README',
|
74
|
+
'README.rdoc',
|
107
75
|
'LICENSE')
|
108
76
|
end
|
109
77
|
|
@@ -115,45 +83,4 @@ Rake::TestTask.new do |t|
|
|
115
83
|
t.test_files = Dir['test/test_suite.rb']
|
116
84
|
t.verbose = true
|
117
85
|
t.warning = true
|
118
|
-
end
|
119
|
-
|
120
|
-
require 'fileutils'
|
121
|
-
|
122
|
-
desc 'Buildr ruby_prof.so'
|
123
|
-
task :build do
|
124
|
-
build(false)
|
125
|
-
end
|
126
|
-
|
127
|
-
def build(with_debug)
|
128
|
-
Dir.chdir('ext/ruby_prof') do
|
129
|
-
unless File.exist? 'Makefile'
|
130
|
-
if with_debug
|
131
|
-
system(Gem.ruby + " -d extconf.rb")
|
132
|
-
else
|
133
|
-
system(Gem.ruby + " extconf.rb")
|
134
|
-
end
|
135
|
-
system("make clean")
|
136
|
-
end
|
137
|
-
system("make")
|
138
|
-
FileUtils.cp 'ruby_prof.so', '../../lib'
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
desc 'build ruby_prof.so with verbose debugging enabled'
|
143
|
-
task :build_debug do
|
144
|
-
build(true)
|
145
|
-
end
|
146
|
-
|
147
|
-
task :cleanr do
|
148
|
-
FileUtils.rm 'lib/ruby_prof.so' if File.exist? 'lib/ruby_prof.so'
|
149
|
-
Dir.chdir('ext/ruby_prof') do
|
150
|
-
if File.exist? 'Makefile'
|
151
|
-
system("make clean")
|
152
|
-
FileUtils.rm 'Makefile'
|
153
|
-
end
|
154
|
-
Dir.glob('*~') do |file|
|
155
|
-
FileUtils.rm file
|
156
|
-
end
|
157
|
-
end
|
158
|
-
system("rm -rf pkg")
|
159
|
-
end
|
86
|
+
end
|
data/bin/ruby-prof
CHANGED
@@ -8,44 +8,14 @@
|
|
8
8
|
#
|
9
9
|
# ruby_prof [options] <script.rb> [--] [script-options]"
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# flat - Prints a flat profile as text (default).
|
14
|
-
# flat_with_line_numbers - Above, with line numbers
|
15
|
-
# graph - Prints a graph profile as text.
|
16
|
-
# graph_html - Prints a graph profile as html.
|
17
|
-
# call_tree - format for KCacheGrind
|
18
|
-
# -f, --file=path Output results to a file instead of standard out.
|
19
|
-
# -m, --min_percent=min_percent The minimum percent a method must take before ',
|
20
|
-
# being included in output reports. Should be an
|
21
|
-
# integer between 1 and 100. 0 means all methods are printed.
|
22
|
-
# --mode=measure_mode Select a measurement mode:
|
23
|
-
# process - Use process time (default).
|
24
|
-
# wall - Use wall time.
|
25
|
-
# cpu - Use the CPU clock counter
|
26
|
-
# (only supported on Pentium and PowerPCs).
|
27
|
-
# allocations - Tracks object allocations
|
28
|
-
# (requires a patched Ruby interpreter).
|
29
|
-
# memory - Tracks total memory size
|
30
|
-
# (requires a patched Ruby interpreter).
|
31
|
-
# gc_runs - Tracks number of garbage collection runs
|
32
|
-
# (requires a patched Ruby interpreter).
|
33
|
-
# gc_time - Tracks time spent doing garbage collection
|
34
|
-
# (requires a patched Ruby interpreter).
|
35
|
-
# --replace-progname Replace $0 when loading the .rb files.
|
36
|
-
# --specialized-instruction Turn on specialized instruction.
|
37
|
-
# -h, --help Show help message
|
38
|
-
# --version Show version
|
39
|
-
# -v Show version, set $VERBOSE to true, run file
|
40
|
-
# -d Set $DEBUG to true
|
41
|
-
#
|
42
|
-
#
|
43
|
-
# 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]
|
11
|
+
# Various options:
|
12
|
+
# run "$ ruby-prof --help" to see them
|
44
13
|
#
|
14
|
+
# See also the readme "reports" section for the various outputs
|
45
15
|
|
46
16
|
require 'ostruct'
|
47
17
|
require 'optparse'
|
48
|
-
require 'ruby-prof'
|
18
|
+
require File.expand_path('../../lib/ruby-prof', __FILE__)
|
49
19
|
|
50
20
|
options = OpenStruct.new
|
51
21
|
options.measure_mode = RubyProf::PROCESS_TIME
|
@@ -57,19 +27,21 @@ options.specialized_instruction = false
|
|
57
27
|
|
58
28
|
opts = OptionParser.new do |opts|
|
59
29
|
opts.banner = "ruby_prof #{RubyProf::VERSION}\n" +
|
60
|
-
"Usage:
|
30
|
+
"Usage: ruby-prof [options] <script.rb> [--] [profiled-script-command-line-options]"
|
61
31
|
|
62
32
|
opts.separator ""
|
63
33
|
opts.separator "Options:"
|
64
34
|
|
65
35
|
|
66
|
-
opts.on('-p printer', '--printer=printer', [:flat, :flat_with_line_numbers, :graph, :graph_html, :call_tree],
|
36
|
+
opts.on('-p printer', '--printer=printer', [:flat, :flat_with_line_numbers, :graph, :graph_html, :call_tree, :call_stack, :dot],
|
67
37
|
'Select a printer:',
|
68
38
|
' flat - Prints a flat profile as text (default).',
|
69
39
|
' flat_with_line_numbers - same as flat, with line numbers.',
|
70
40
|
' graph - Prints a graph profile as text.',
|
71
41
|
' graph_html - Prints a graph profile as html.',
|
72
|
-
' call_tree - format for KCacheGrind'
|
42
|
+
' call_tree - format for KCacheGrind',
|
43
|
+
' call_stack - prints a HTML visualization of the call tree',
|
44
|
+
' dot - Prints a graph profile as a dot file'
|
73
45
|
) do |printer|
|
74
46
|
|
75
47
|
|
@@ -84,6 +56,10 @@ opts = OptionParser.new do |opts|
|
|
84
56
|
options.printer = RubyProf::GraphHtmlPrinter
|
85
57
|
when :call_tree
|
86
58
|
options.printer = RubyProf::CallTreePrinter
|
59
|
+
when :call_stack
|
60
|
+
options.printer = RubyProf::CallStackPrinter
|
61
|
+
when :dot
|
62
|
+
options.printer = RubyProf::DotPrinter
|
87
63
|
end
|
88
64
|
end
|
89
65
|
|
@@ -97,6 +73,7 @@ opts = OptionParser.new do |opts|
|
|
97
73
|
opts.on('-f path', '--file=path',
|
98
74
|
'Output results to a file instead of standard out.') do |file|
|
99
75
|
options.file = file
|
76
|
+
options.old_wd = Dir.pwd
|
100
77
|
end
|
101
78
|
|
102
79
|
opts.on('--mode=measure_mode',
|
@@ -127,7 +104,26 @@ opts = OptionParser.new do |opts|
|
|
127
104
|
options.measure_mode = RubyProf::GC_TIME
|
128
105
|
end
|
129
106
|
end
|
130
|
-
|
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
|
+
|
131
127
|
opts.on("--replace-progname", "Replace $0 when loading the .rb files.") do
|
132
128
|
options.replace_prog_name = true
|
133
129
|
end
|
@@ -148,15 +144,34 @@ opts = OptionParser.new do |opts|
|
|
148
144
|
exit
|
149
145
|
end
|
150
146
|
|
151
|
-
opts.on("-v","Show version, set $VERBOSE to true, profile script") do
|
152
|
-
puts "
|
153
|
-
|
154
|
-
$VERBOSE= true
|
147
|
+
opts.on("-v","Show version, set $VERBOSE to true, profile script if option given") do
|
148
|
+
puts "ruby version: " + [RUBY_PATCHLEVEL, RUBY_PLATFORM, RUBY_VERSION].join(' ')
|
149
|
+
$VERBOSE = true
|
155
150
|
end
|
156
151
|
|
157
152
|
opts.on("-d", "Set $DEBUG to true") do
|
158
153
|
$DEBUG = true
|
159
154
|
end
|
155
|
+
|
156
|
+
opts.on('-R lib', '--require-noprof lib', 'require a specific library (not profiled)') do |lib|
|
157
|
+
options.pre_libs ||= []
|
158
|
+
options.pre_libs << lib
|
159
|
+
end
|
160
|
+
|
161
|
+
opts.on('-E code', '--eval-noprof code', 'execute the ruby statements (not profiled)') do |code|
|
162
|
+
options.pre_exec ||= []
|
163
|
+
options.pre_exec << code
|
164
|
+
end
|
165
|
+
|
166
|
+
opts.on('-r lib', '--require lib', 'require a specific library') do |lib|
|
167
|
+
options.libs ||= []
|
168
|
+
options.libs << lib
|
169
|
+
end
|
170
|
+
|
171
|
+
opts.on('-e code', '--eval', 'execute the ruby statements') do |code|
|
172
|
+
options.exec ||= []
|
173
|
+
options.exec << code
|
174
|
+
end
|
160
175
|
end
|
161
176
|
|
162
177
|
begin
|
@@ -170,7 +185,7 @@ rescue OptionParser::InvalidOption, OptionParser::InvalidArgument,
|
|
170
185
|
end
|
171
186
|
|
172
187
|
# Make sure the user specified at least one file
|
173
|
-
if ARGV.length < 1
|
188
|
+
if ARGV.length < 1 and not options.exec
|
174
189
|
puts opts
|
175
190
|
puts ""
|
176
191
|
puts "Must specify a script to run"
|
@@ -188,15 +203,19 @@ at_exit {
|
|
188
203
|
|
189
204
|
# Create a printer
|
190
205
|
printer = options.printer.new(result)
|
206
|
+
printer_options = {:min_percent => options.min_percent, :sort_method => options.sort_method}
|
191
207
|
|
192
208
|
# Get output
|
193
209
|
if options.file
|
194
|
-
|
195
|
-
|
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.
|
211
|
+
Dir.chdir(options.old_wd) do
|
212
|
+
File.open(options.file, 'w') do |file|
|
213
|
+
printer.print(file, printer_options)
|
214
|
+
end
|
196
215
|
end
|
197
216
|
else
|
198
217
|
# Print out results
|
199
|
-
printer.print(STDOUT,
|
218
|
+
printer.print(STDOUT, printer_options)
|
200
219
|
end
|
201
220
|
}
|
202
221
|
|
@@ -217,8 +236,28 @@ if options.replace_prog_name
|
|
217
236
|
$0 = File.expand_path(script)
|
218
237
|
end
|
219
238
|
|
239
|
+
if options.pre_libs
|
240
|
+
options.pre_libs.each { |l| require l }
|
241
|
+
end
|
242
|
+
|
243
|
+
if options.pre_exec
|
244
|
+
options.pre_exec.each { |c| eval c }
|
245
|
+
end
|
246
|
+
|
247
|
+
# do not pollute profiling report with OpenStruct#libs
|
248
|
+
ol = options.libs
|
249
|
+
oe = options.exec
|
250
|
+
|
220
251
|
# Start profiling
|
221
252
|
RubyProf.start
|
222
253
|
|
254
|
+
if ol
|
255
|
+
ol.each { |l| require l }
|
256
|
+
end
|
257
|
+
|
258
|
+
if oe
|
259
|
+
oe.each { |c| eval c }
|
260
|
+
end
|
261
|
+
|
223
262
|
# Load the script
|
224
|
-
load script
|
263
|
+
load script if script
|
data/examples/empty.png
ADDED
Binary file
|
data/examples/graph.dot
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
digraph "Profile" {
|
2
|
+
label="WALL_TIME >=0%\nTotal: 1.382985";
|
3
|
+
labelloc=t;
|
4
|
+
labeljust=l;
|
5
|
+
subgraph "Thread 2148237740" {
|
6
|
+
2159427600 [label="[]=\n(0%)"];
|
7
|
+
2159427680 [label="%\n(15%)"];
|
8
|
+
2159427760 [label="run_primes\n(100%)"];
|
9
|
+
2159427760 -> 2159428600 [label="2/2" fontsize=10 fontcolor="#666666"];
|
10
|
+
2159427760 -> 2159428300 [label="2/2" fontsize=10 fontcolor="#666666"];
|
11
|
+
2159427840 [label="new\n(0%)"];
|
12
|
+
2159427840 -> 2159428080 [label="2/2" fontsize=10 fontcolor="#666666"];
|
13
|
+
2159427840 -> 2159428760 [label="2/2" fontsize=10 fontcolor="#666666"];
|
14
|
+
2159427920 [label="rand\n(0%)"];
|
15
|
+
2159428000 [label="-\n(0%)"];
|
16
|
+
2159428080 [label="initialize\n(0%)"];
|
17
|
+
2159428160 [label="each_index\n(1%)"];
|
18
|
+
2159428160 -> 2159427920 [label="20000/20000" fontsize=10 fontcolor="#666666"];
|
19
|
+
2159428160 -> 2159427600 [label="20000/20000" fontsize=10 fontcolor="#666666"];
|
20
|
+
2159428220 [label="go\n(49%)"];
|
21
|
+
2159428220 -> 2159427760 [label="1/2" fontsize=10 fontcolor="#666666"];
|
22
|
+
2159428300 [label="make_random_array\n(1%)"];
|
23
|
+
2159428300 -> 2159428160 [label="2/2" fontsize=10 fontcolor="#666666"];
|
24
|
+
2159428300 -> 2159427840 [label="2/2" fontsize=10 fontcolor="#666666"];
|
25
|
+
2159428360 [label="setup\n(100%)"];
|
26
|
+
2159428360 -> 2159427760 [label="1/2" fontsize=10 fontcolor="#666666"];
|
27
|
+
2159428360 -> 2159428220 [label="1/1" fontsize=10 fontcolor="#666666"];
|
28
|
+
2159428440 [label="select\n(99%)"];
|
29
|
+
2159428440 -> 2159428520 [label="20000/20000" fontsize=10 fontcolor="#666666"];
|
30
|
+
2159428520 [label="is_prime\n(98%)"];
|
31
|
+
2159428520 -> 2159428680 [label="20000/20000" fontsize=10 fontcolor="#666666"];
|
32
|
+
2159428520 -> 2159428000 [label="20000/20000" fontsize=10 fontcolor="#666666"];
|
33
|
+
2159428600 [label="find_primes\n(99%)"];
|
34
|
+
2159428600 -> 2159428440 [label="2/2" fontsize=10 fontcolor="#666666"];
|
35
|
+
2159428680 [label="upto\n(97%)"];
|
36
|
+
2159428680 -> 2159427680 [label="1562487/1562487" fontsize=10 fontcolor="#666666"];
|
37
|
+
2159428680 -> 2159428920 [label="1562487/1562487" fontsize=10 fontcolor="#666666"];
|
38
|
+
2159428760 [label="allocate\n(0%)"];
|
39
|
+
2159428920 [label="==\n(12%)"];
|
40
|
+
}
|
41
|
+
subgraph cluster_2159103200 {
|
42
|
+
label = "Object";
|
43
|
+
fontcolor = "#666666";
|
44
|
+
fontsize = 16;
|
45
|
+
color = "#666666";
|
46
|
+
2159428600;
|
47
|
+
2159428520;
|
48
|
+
2159428300;
|
49
|
+
2159427760;
|
50
|
+
}
|
51
|
+
subgraph cluster_2159103260 {
|
52
|
+
label = "Integer";
|
53
|
+
fontcolor = "#666666";
|
54
|
+
fontsize = 16;
|
55
|
+
color = "#666666";
|
56
|
+
2159428680;
|
57
|
+
}
|
58
|
+
subgraph cluster_2159103060 {
|
59
|
+
label = "PrintersTest";
|
60
|
+
fontcolor = "#666666";
|
61
|
+
fontsize = 16;
|
62
|
+
color = "#666666";
|
63
|
+
2159428360;
|
64
|
+
2159428220;
|
65
|
+
}
|
66
|
+
subgraph cluster_2159103120 {
|
67
|
+
label = "Array";
|
68
|
+
fontcolor = "#666666";
|
69
|
+
fontsize = 16;
|
70
|
+
color = "#666666";
|
71
|
+
2159428440;
|
72
|
+
2159428160;
|
73
|
+
2159428080;
|
74
|
+
2159427600;
|
75
|
+
}
|
76
|
+
subgraph cluster_2159103340 {
|
77
|
+
label = "<Class::Array>";
|
78
|
+
fontcolor = "#666666";
|
79
|
+
fontsize = 16;
|
80
|
+
color = "#666666";
|
81
|
+
2159428760;
|
82
|
+
}
|
83
|
+
subgraph cluster_2159102840 {
|
84
|
+
label = "Class";
|
85
|
+
fontcolor = "#666666";
|
86
|
+
fontsize = 16;
|
87
|
+
color = "#666666";
|
88
|
+
2159427840;
|
89
|
+
}
|
90
|
+
subgraph cluster_2159102980 {
|
91
|
+
label = "Kernel";
|
92
|
+
fontcolor = "#666666";
|
93
|
+
fontsize = 16;
|
94
|
+
color = "#666666";
|
95
|
+
2159427920;
|
96
|
+
}
|
97
|
+
subgraph cluster_2159103400 {
|
98
|
+
label = "Fixnum";
|
99
|
+
fontcolor = "#666666";
|
100
|
+
fontsize = 16;
|
101
|
+
color = "#666666";
|
102
|
+
2159428920;
|
103
|
+
2159428000;
|
104
|
+
2159427680;
|
105
|
+
}
|
106
|
+
}
|