acunote-ruby-prof 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +240 -0
- data/LICENSE +23 -0
- data/README.rdoc +439 -0
- data/Rakefile +148 -0
- data/bin/ruby-prof +236 -0
- data/examples/empty.png +0 -0
- data/examples/flat.txt +55 -0
- data/examples/graph.dot +106 -0
- data/examples/graph.html +823 -0
- data/examples/graph.png +0 -0
- data/examples/graph.txt +170 -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 +43 -0
- data/ext/ruby_prof/measure_allocations.h +58 -0
- data/ext/ruby_prof/measure_cpu_time.h +152 -0
- data/ext/ruby_prof/measure_gc_runs.h +76 -0
- data/ext/ruby_prof/measure_gc_time.h +57 -0
- data/ext/ruby_prof/measure_memory.h +101 -0
- data/ext/ruby_prof/measure_process_time.h +52 -0
- data/ext/ruby_prof/measure_wall_time.h +53 -0
- data/ext/ruby_prof/mingw/Rakefile +23 -0
- data/ext/ruby_prof/mingw/build.rake +38 -0
- data/ext/ruby_prof/ruby_prof.c +1834 -0
- data/ext/ruby_prof/ruby_prof.h +190 -0
- data/ext/ruby_prof/version.h +4 -0
- data/lib/ruby-prof.rb +62 -0
- data/lib/ruby-prof/abstract_printer.rb +41 -0
- data/lib/ruby-prof/aggregate_call_info.rb +68 -0
- data/lib/ruby-prof/call_info.rb +112 -0
- data/lib/ruby-prof/call_stack_printer.rb +751 -0
- data/lib/ruby-prof/call_tree_printer.rb +133 -0
- data/lib/ruby-prof/dot_printer.rb +153 -0
- data/lib/ruby-prof/empty.png +0 -0
- data/lib/ruby-prof/flat_printer.rb +78 -0
- data/lib/ruby-prof/flat_printer_with_line_numbers.rb +72 -0
- data/lib/ruby-prof/graph_html_printer.rb +278 -0
- data/lib/ruby-prof/graph_printer.rb +245 -0
- data/lib/ruby-prof/method_info.rb +131 -0
- data/lib/ruby-prof/minus.png +0 -0
- data/lib/ruby-prof/multi_printer.rb +54 -0
- data/lib/ruby-prof/plus.png +0 -0
- data/lib/ruby-prof/rack.rb +30 -0
- data/lib/ruby-prof/result.rb +70 -0
- data/lib/ruby-prof/symbol_to_proc.rb +8 -0
- data/lib/ruby-prof/task.rb +146 -0
- data/lib/ruby-prof/test.rb +148 -0
- data/lib/unprof.rb +8 -0
- data/rails/environment/profile.rb +24 -0
- data/rails/example/example_test.rb +9 -0
- data/rails/profile_test_helper.rb +21 -0
- data/test/aggregate_test.rb +136 -0
- data/test/basic_test.rb +290 -0
- data/test/current_failures_windows +8 -0
- data/test/do_nothing.rb +0 -0
- data/test/duplicate_names_test.rb +32 -0
- data/test/enumerable_test.rb +16 -0
- data/test/exceptions_test.rb +15 -0
- data/test/exclude_threads_test.rb +54 -0
- data/test/exec_test.rb +14 -0
- data/test/line_number_test.rb +73 -0
- data/test/measurement_test.rb +122 -0
- data/test/method_elimination_test.rb +74 -0
- data/test/module_test.rb +44 -0
- data/test/multi_printer_test.rb +81 -0
- data/test/no_method_class_test.rb +13 -0
- data/test/prime.rb +55 -0
- data/test/prime_test.rb +13 -0
- data/test/printers_test.rb +164 -0
- data/test/recursive_test.rb +236 -0
- data/test/ruby-prof-bin +20 -0
- data/test/singleton_test.rb +38 -0
- data/test/stack_printer_test.rb +74 -0
- data/test/stack_test.rb +138 -0
- data/test/start_stop_test.rb +112 -0
- data/test/test_suite.rb +32 -0
- data/test/thread_test.rb +173 -0
- data/test/unique_call_path_test.rb +225 -0
- metadata +185 -0
data/Rakefile
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'date'
|
6
|
+
|
7
|
+
# ------- Version ----
|
8
|
+
# Read version from header file
|
9
|
+
version_header = File.read('ext/ruby_prof/version.h')
|
10
|
+
match = version_header.match(/RUBY_PROF_VERSION\s*["](\d.+)["]/)
|
11
|
+
raise(RuntimeError, "Could not determine RUBY_PROF_VERSION") if not match
|
12
|
+
RUBY_PROF_VERSION = match[1]
|
13
|
+
|
14
|
+
|
15
|
+
# ------- Default Package ----------
|
16
|
+
FILES = FileList[
|
17
|
+
'Rakefile',
|
18
|
+
'README.rdoc',
|
19
|
+
'LICENSE',
|
20
|
+
'CHANGES',
|
21
|
+
'bin/*',
|
22
|
+
'doc/**/*',
|
23
|
+
'examples/*',
|
24
|
+
'ext/ruby_prof/*.c',
|
25
|
+
'ext/ruby_prof/*.h',
|
26
|
+
'ext/ruby_prof/mingw/Rakefile',
|
27
|
+
'ext/ruby_prof/mingw/build.rake',
|
28
|
+
'ext/vc/*.sln',
|
29
|
+
'ext/vc/*.vcproj',
|
30
|
+
'lib/**/*',
|
31
|
+
'rails/**/*',
|
32
|
+
'test/*'
|
33
|
+
]
|
34
|
+
|
35
|
+
# Default GEM Specification
|
36
|
+
default_spec = Gem::Specification.new do |spec|
|
37
|
+
spec.name = "acunote-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, Stefan Kaes"
|
53
|
+
spec.email = "shugo@ruby-lang.org, cfis@savagexi.com, rogerdpack@gmail.com, skaes@railsexpress.de"
|
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
|
+
|
70
|
+
desc 'build native .gem files -- use like "native_gems clobber cross native gem"--for non native gem creation use "native_gems clobber" then "clean gem"'
|
71
|
+
task :native_gems do
|
72
|
+
ENV['RUBY_CC_VERSION'] = '1.8.6:1.9.1'
|
73
|
+
require 'rake/extensiontask'
|
74
|
+
Rake::ExtensionTask.new('ruby_prof', default_spec) do |ext|
|
75
|
+
ext.cross_compile = true
|
76
|
+
ext.cross_platform = ['x86-mswin32-60', 'x86-mingw32-60']
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Rake task to build the default package
|
81
|
+
Rake::GemPackageTask.new(default_spec) do |pkg|
|
82
|
+
pkg.need_tar = true
|
83
|
+
#pkg.need_zip = true
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
# --------- RDoc Documentation ------
|
88
|
+
desc "Generate rdoc documentation"
|
89
|
+
Rake::RDocTask.new("rdoc") do |rdoc|
|
90
|
+
rdoc.rdoc_dir = 'doc'
|
91
|
+
rdoc.title = "ruby-prof"
|
92
|
+
# Show source inline with line numbers
|
93
|
+
rdoc.options << "--inline-source" << "--line-numbers"
|
94
|
+
# Make the readme file the start page for the generated html
|
95
|
+
rdoc.options << '--main' << 'README.rdoc'
|
96
|
+
rdoc.rdoc_files.include('bin/**/*',
|
97
|
+
'doc/*.rdoc',
|
98
|
+
'examples/flat.txt',
|
99
|
+
'examples/graph.txt',
|
100
|
+
'examples/graph.html',
|
101
|
+
'lib/**/*.rb',
|
102
|
+
'ext/ruby_prof/ruby_prof.c',
|
103
|
+
'ext/ruby_prof/version.h',
|
104
|
+
'ext/ruby_prof/measure_*.h',
|
105
|
+
'README.rdoc',
|
106
|
+
'LICENSE')
|
107
|
+
end
|
108
|
+
|
109
|
+
task :default => :package
|
110
|
+
|
111
|
+
desc 'Run the ruby-prof test suite'
|
112
|
+
Rake::TestTask.new do |t|
|
113
|
+
t.libs += %w(lib ext test)
|
114
|
+
t.test_files = Dir['test/test_suite.rb']
|
115
|
+
t.verbose = true
|
116
|
+
t.warning = true
|
117
|
+
end
|
118
|
+
|
119
|
+
require 'fileutils'
|
120
|
+
|
121
|
+
desc 'Build ruby_prof.so'
|
122
|
+
task :build do
|
123
|
+
Dir.chdir('ext/ruby_prof') do
|
124
|
+
unless File.exist? 'Makefile'
|
125
|
+
system(Gem.ruby + " extconf.rb")
|
126
|
+
system("make clean")
|
127
|
+
end
|
128
|
+
system("make")
|
129
|
+
FileUtils.cp 'ruby_prof.so', '../../lib' if File.exist? 'lib/ruby_prof.so'
|
130
|
+
FileUtils.cp 'ruby_prof.bundle', '../../lib' if File.exist? 'lib/ruby_prof.bundle'
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
desc 'clean stuff'
|
135
|
+
task :cleanr do
|
136
|
+
FileUtils.rm 'lib/ruby_prof.so' if File.exist? 'lib/ruby_prof.so'
|
137
|
+
FileUtils.rm 'lib/ruby_prof.bundle' if File.exist? 'lib/ruby_prof.bundle'
|
138
|
+
Dir.chdir('ext/ruby_prof') do
|
139
|
+
if File.exist? 'Makefile'
|
140
|
+
system("make clean")
|
141
|
+
FileUtils.rm 'Makefile'
|
142
|
+
end
|
143
|
+
Dir.glob('*~') do |file|
|
144
|
+
FileUtils.rm file
|
145
|
+
end
|
146
|
+
end
|
147
|
+
system("rm -rf pkg")
|
148
|
+
end
|
data/bin/ruby-prof
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
# == Synopsis
|
4
|
+
#
|
5
|
+
# Profiles a Ruby program.
|
6
|
+
#
|
7
|
+
# == Usage
|
8
|
+
#
|
9
|
+
# ruby_prof [options] <script.rb> [--] [script-options]"
|
10
|
+
#
|
11
|
+
# Options:
|
12
|
+
# -p, --printer=printer Select a printer:
|
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
|
+
# call_stack - prints a HTML visualization of the call tree
|
19
|
+
# dot - Prints a graph profile as a dot file
|
20
|
+
# -f, --file=path Output results to a file instead of standard out.
|
21
|
+
# -m, --min_percent=min_percent The minimum percent a method must take before ',
|
22
|
+
# being included in output reports. Should be an
|
23
|
+
# integer between 1 and 100. 0 means all methods are printed.
|
24
|
+
# --mode=measure_mode Select a measurement mode:
|
25
|
+
# process - Use process time (default).
|
26
|
+
# wall - Use wall time.
|
27
|
+
# cpu - Use the CPU clock counter
|
28
|
+
# (only supported on Pentium and PowerPCs).
|
29
|
+
# allocations - Tracks object allocations
|
30
|
+
# (requires a patched Ruby interpreter).
|
31
|
+
# memory - Tracks total memory size
|
32
|
+
# (requires a patched Ruby interpreter).
|
33
|
+
# gc_runs - Tracks number of garbage collection runs
|
34
|
+
# (requires a patched Ruby interpreter).
|
35
|
+
# gc_time - Tracks time spent doing garbage collection
|
36
|
+
# (requires a patched Ruby interpreter).
|
37
|
+
# --replace-progname Replace $0 when loading the .rb files.
|
38
|
+
# --specialized-instruction Turn on specialized instruction.
|
39
|
+
# -h, --help Show help message
|
40
|
+
# --version Show version
|
41
|
+
# -v Show version, set $VERBOSE to true, run file
|
42
|
+
# -d Set $DEBUG to true
|
43
|
+
#
|
44
|
+
#
|
45
|
+
# 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]
|
46
|
+
#
|
47
|
+
|
48
|
+
require 'ostruct'
|
49
|
+
require 'optparse'
|
50
|
+
require 'ruby-prof'
|
51
|
+
|
52
|
+
options = OpenStruct.new
|
53
|
+
options.measure_mode = RubyProf::PROCESS_TIME
|
54
|
+
options.printer = RubyProf::FlatPrinter
|
55
|
+
options.min_percent = 0
|
56
|
+
options.file = nil
|
57
|
+
options.replace_prog_name = false
|
58
|
+
options.specialized_instruction = false
|
59
|
+
|
60
|
+
opts = OptionParser.new do |opts|
|
61
|
+
opts.banner = "ruby_prof #{RubyProf::VERSION}\n" +
|
62
|
+
"Usage: ruby_prof [options] <script.rb> [--] [script-options]"
|
63
|
+
|
64
|
+
opts.separator ""
|
65
|
+
opts.separator "Options:"
|
66
|
+
|
67
|
+
|
68
|
+
opts.on('-p printer', '--printer=printer', [:flat, :flat_with_line_numbers, :graph, :graph_html, :call_tree, :call_stack, :dot],
|
69
|
+
'Select a printer:',
|
70
|
+
' flat - Prints a flat profile as text (default).',
|
71
|
+
' flat_with_line_numbers - same as flat, with line numbers.',
|
72
|
+
' graph - Prints a graph profile as text.',
|
73
|
+
' graph_html - Prints a graph profile as html.',
|
74
|
+
' call_tree - format for KCacheGrind',
|
75
|
+
' call_stack - prints a HTML visualization of the call tree',
|
76
|
+
' dot - Prints a graph profile as a dot file'
|
77
|
+
) do |printer|
|
78
|
+
|
79
|
+
|
80
|
+
case printer
|
81
|
+
when :flat
|
82
|
+
options.printer = RubyProf::FlatPrinter
|
83
|
+
when :flat_with_line_numbers
|
84
|
+
options.printer = RubyProf::FlatPrinterWithLineNumbers
|
85
|
+
when :graph
|
86
|
+
options.printer = RubyProf::GraphPrinter
|
87
|
+
when :graph_html
|
88
|
+
options.printer = RubyProf::GraphHtmlPrinter
|
89
|
+
when :call_tree
|
90
|
+
options.printer = RubyProf::CallTreePrinter
|
91
|
+
when :call_stack
|
92
|
+
options.printer = RubyProf::CallStackPrinter
|
93
|
+
when :dot
|
94
|
+
options.printer = RubyProf::DotPrinter
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
opts.on('-m min_percent', '--min_percent=min_percent', Float,
|
99
|
+
'The minimum percent a method must take before ',
|
100
|
+
' being included in output reports.',
|
101
|
+
' this option is not supported for call tree.') do |min_percent|
|
102
|
+
options.min_percent = min_percent
|
103
|
+
end
|
104
|
+
|
105
|
+
opts.on('-f path', '--file=path',
|
106
|
+
'Output results to a file instead of standard out.') do |file|
|
107
|
+
options.file = file
|
108
|
+
options.old_wd = Dir.pwd
|
109
|
+
end
|
110
|
+
|
111
|
+
opts.on('--mode=measure_mode',
|
112
|
+
[:process, :wall, :cpu, :allocations, :memory, :gc_runs, :gc_time],
|
113
|
+
'Select what ruby-prof should measure:',
|
114
|
+
' process - Process time (default).',
|
115
|
+
' wall - Wall time.',
|
116
|
+
' cpu - CPU time (Pentium and PowerPCs only).',
|
117
|
+
' allocations - Object allocations (requires patched Ruby interpreter).',
|
118
|
+
' memory - Allocated memory in KB (requires patched Ruby interpreter).',
|
119
|
+
' gc_runs - Number of garbage collections (requires patched Ruby interpreter).',
|
120
|
+
' gc_time - Time spent in garbage collection (requires patched Ruby interpreter).') do |measure_mode|
|
121
|
+
|
122
|
+
case measure_mode
|
123
|
+
when :process
|
124
|
+
options.measure_mode = RubyProf::PROCESS_TIME
|
125
|
+
when :wall
|
126
|
+
options.measure_mode = RubyProf::WALL_TIME
|
127
|
+
when :cpu
|
128
|
+
options.measure_mode = RubyProf::CPU_TIME
|
129
|
+
when :allocations
|
130
|
+
options.measure_mode = RubyProf::ALLOCATIONS
|
131
|
+
when :memory
|
132
|
+
options.measure_mode = RubyProf::MEMORY
|
133
|
+
when :gc_runs
|
134
|
+
options.measure_mode = RubyProf::GC_RUNS
|
135
|
+
when :gc_time
|
136
|
+
options.measure_mode = RubyProf::GC_TIME
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
opts.on("--replace-progname", "Replace $0 when loading the .rb files.") do
|
141
|
+
options.replace_prog_name = true
|
142
|
+
end
|
143
|
+
|
144
|
+
if defined?(VM)
|
145
|
+
opts.on("--specialized-instruction", "Turn on specified instruction.") do
|
146
|
+
options.specialized_instruction = true
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
opts.on_tail("-h", "--help", "Show help message") do
|
151
|
+
puts opts
|
152
|
+
exit
|
153
|
+
end
|
154
|
+
|
155
|
+
opts.on_tail("--version", "Show version #{RubyProf::VERSION}") do
|
156
|
+
puts "ruby_prof " + RubyProf::VERSION
|
157
|
+
exit
|
158
|
+
end
|
159
|
+
|
160
|
+
opts.on("-v","Show version, set $VERBOSE to true, profile script") do
|
161
|
+
puts "ruby_prof " + RubyProf::VERSION
|
162
|
+
puts "ruby " + RUBY_DESCRIPTION
|
163
|
+
$VERBOSE= true
|
164
|
+
end
|
165
|
+
|
166
|
+
opts.on("-d", "Set $DEBUG to true") do
|
167
|
+
$DEBUG = true
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
begin
|
172
|
+
opts.parse! ARGV
|
173
|
+
rescue OptionParser::InvalidOption, OptionParser::InvalidArgument,
|
174
|
+
OptionParser::MissingArgument => e
|
175
|
+
puts opts
|
176
|
+
puts
|
177
|
+
puts e.message
|
178
|
+
exit(-1)
|
179
|
+
end
|
180
|
+
|
181
|
+
# Make sure the user specified at least one file
|
182
|
+
if ARGV.length < 1
|
183
|
+
puts opts
|
184
|
+
puts ""
|
185
|
+
puts "Must specify a script to run"
|
186
|
+
exit(-1)
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
# Install at_exit handler. It is important that we do this
|
191
|
+
# before loading the scripts so our at_exit handler run
|
192
|
+
# *after* any other one that will be installed.
|
193
|
+
|
194
|
+
at_exit {
|
195
|
+
# Stop profiling
|
196
|
+
result = RubyProf.stop
|
197
|
+
|
198
|
+
# Create a printer
|
199
|
+
printer = options.printer.new(result)
|
200
|
+
|
201
|
+
# Get output
|
202
|
+
if options.file
|
203
|
+
# 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.
|
204
|
+
Dir.chdir(options.old_wd) do
|
205
|
+
File.open(options.file, 'w') do |file|
|
206
|
+
printer.print(file, {:min_percent => options.min_percent})
|
207
|
+
end
|
208
|
+
end
|
209
|
+
else
|
210
|
+
# Print out results
|
211
|
+
printer.print(STDOUT, {:min_percent => options.min_percent})
|
212
|
+
end
|
213
|
+
}
|
214
|
+
|
215
|
+
# Now set measure mode
|
216
|
+
RubyProf.measure_mode = options.measure_mode
|
217
|
+
|
218
|
+
# Set VM compile option
|
219
|
+
if defined?(VM)
|
220
|
+
VM::InstructionSequence.compile_option = {
|
221
|
+
:trace_instruction => true,
|
222
|
+
:specialized_instruction => options.specialized_instruction
|
223
|
+
}
|
224
|
+
end
|
225
|
+
|
226
|
+
# Get the script we will execute
|
227
|
+
script = ARGV.shift
|
228
|
+
if options.replace_prog_name
|
229
|
+
$0 = File.expand_path(script)
|
230
|
+
end
|
231
|
+
|
232
|
+
# Start profiling
|
233
|
+
RubyProf.start
|
234
|
+
|
235
|
+
# Load the script
|
236
|
+
load script
|
data/examples/empty.png
ADDED
Binary file
|
data/examples/flat.txt
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
= Flat Profiles
|
2
|
+
|
3
|
+
Flat profiles show the total amount of time spent in each method.
|
4
|
+
As an example, here is the output from running printers_test.rb.
|
5
|
+
|
6
|
+
Thread ID: 21277412
|
7
|
+
%self cumulative total self children calls self/call total/call name
|
8
|
+
46.34 4.06 8.72 4.06 4.66 501 0.01 0.02 Integer#upto
|
9
|
+
23.89 6.16 2.09 2.09 0.00 61 0.03 0.03 Kernel.sleep
|
10
|
+
15.12 7.48 1.33 1.33 0.00 250862 0.00 0.00 Fixnum#%
|
11
|
+
14.13 8.72 1.24 1.24 0.00 250862 0.00 0.00 Fixnum#==
|
12
|
+
0.18 8.74 0.02 0.02 0.00 1 0.02 0.02 Array#each_index
|
13
|
+
0.17 8.75 6.64 0.01 6.63 500 0.00 0.01 Object#is_prime
|
14
|
+
0.17 8.77 6.66 0.01 6.64 1 0.01 6.66 Array#select
|
15
|
+
0.00 8.77 0.00 0.00 0.00 501 0.00 0.00 Fixnum#-
|
16
|
+
0.00 8.77 0.00 0.00 0.00 1 0.00 0.00 Array#first
|
17
|
+
0.00 8.77 0.00 0.00 0.00 1 0.00 0.00 Array#length
|
18
|
+
0.00 8.77 0.00 0.00 0.00 1 0.00 0.00 Array#initialize
|
19
|
+
0.00 8.77 8.77 0.00 8.77 1 0.00 8.77 Object#run_primes
|
20
|
+
0.00 8.77 0.00 0.00 0.00 1 0.00 0.00 Integer#to_int
|
21
|
+
0.00 8.77 6.66 0.00 6.66 1 0.00 6.66 Object#find_primes
|
22
|
+
0.00 8.77 2.09 0.00 2.09 1 0.00 2.09 Object#find_largest
|
23
|
+
0.00 8.77 0.02 0.00 0.02 1 0.00 0.02 Object#make_random_array
|
24
|
+
0.00 8.77 0.00 0.00 0.00 1 0.00 0.00 Class#new
|
25
|
+
0.00 8.77 0.00 0.00 0.00 500 0.00 0.00 Array#[]=
|
26
|
+
0.00 8.77 0.00 0.00 0.00 61 0.00 0.00 Fixnum#>
|
27
|
+
0.00 8.77 0.00 0.00 0.00 61 0.00 0.00 Array#[]
|
28
|
+
0.00 8.77 8.77 0.00 8.77 1 0.00 8.77 #toplevel
|
29
|
+
0.00 8.77 0.00 0.00 0.00 500 0.00 0.00 Kernel.rand
|
30
|
+
|
31
|
+
All values are in seconds.
|
32
|
+
|
33
|
+
The columns are:
|
34
|
+
|
35
|
+
%self - The percentage of time spent in this method, derived from self_time/total_time
|
36
|
+
cumulative - The sum of the time spent in this method and all the methods listed above it.
|
37
|
+
total - The time spent in this method and its children.
|
38
|
+
self - The time spent in this method.
|
39
|
+
children - The time spent in this method's children.
|
40
|
+
calls - The number of times this method was called.
|
41
|
+
self/call - The average time spent per call in this method.
|
42
|
+
total/call - The average time spent per call in this method and its children.
|
43
|
+
name - The name of the method.
|
44
|
+
|
45
|
+
Methods are sorted based on %self, therefore the methods that execute the longest are listed
|
46
|
+
first.
|
47
|
+
|
48
|
+
The interpretation of method names is:
|
49
|
+
* #toplevel - The root method that calls all other methods
|
50
|
+
* MyObject#test - An instance method "test" of the class "MyObject"
|
51
|
+
* <Object:MyObject>#test - The <> characters indicate a singleton method on a singleton class.
|
52
|
+
|
53
|
+
For example, wee can see that Integer#upto took the most time, 4.06 seconds. An additional
|
54
|
+
4.66 seconds were spent in its children, for a total time of 8.72 seconds.
|
55
|
+
|
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
|
+
}
|