ruby-prof 0.18.0-x64-mingw32 → 1.1.0-x64-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.
- checksums.yaml +4 -4
- data/CHANGES +32 -0
- data/LICENSE +2 -2
- data/README.rdoc +1 -483
- data/Rakefile +3 -6
- data/bin/ruby-prof +65 -30
- data/ext/ruby_prof/extconf.rb +6 -38
- data/ext/ruby_prof/rp_allocation.c +279 -0
- data/ext/ruby_prof/rp_allocation.h +31 -0
- data/ext/ruby_prof/rp_call_info.c +129 -283
- data/ext/ruby_prof/rp_call_info.h +16 -34
- data/ext/ruby_prof/rp_measure_allocations.c +25 -49
- data/ext/ruby_prof/rp_measure_memory.c +21 -56
- data/ext/ruby_prof/rp_measure_process_time.c +35 -39
- data/ext/ruby_prof/rp_measure_wall_time.c +36 -19
- data/ext/ruby_prof/rp_measurement.c +230 -0
- data/ext/ruby_prof/rp_measurement.h +50 -0
- data/ext/ruby_prof/rp_method.c +389 -389
- data/ext/ruby_prof/rp_method.h +34 -39
- data/ext/ruby_prof/rp_profile.c +895 -0
- data/ext/ruby_prof/rp_profile.h +37 -0
- data/ext/ruby_prof/rp_stack.c +103 -80
- data/ext/ruby_prof/rp_stack.h +5 -12
- data/ext/ruby_prof/rp_thread.c +143 -83
- data/ext/ruby_prof/rp_thread.h +15 -6
- data/ext/ruby_prof/ruby_prof.c +11 -757
- data/ext/ruby_prof/ruby_prof.h +4 -47
- data/ext/ruby_prof/vc/ruby_prof.vcxproj +10 -8
- data/lib/{2.6.3 → 2.6.5}/ruby_prof.so +0 -0
- data/lib/ruby-prof.rb +2 -18
- data/lib/ruby-prof/assets/call_stack_printer.html.erb +713 -0
- data/lib/ruby-prof/assets/call_stack_printer.png +0 -0
- data/lib/ruby-prof/assets/graph_printer.html.erb +356 -0
- data/lib/ruby-prof/call_info.rb +35 -93
- data/lib/ruby-prof/call_info_visitor.rb +19 -21
- data/lib/ruby-prof/compatibility.rb +37 -107
- data/lib/ruby-prof/exclude_common_methods.rb +198 -0
- data/lib/ruby-prof/measurement.rb +14 -0
- data/lib/ruby-prof/method_info.rb +52 -83
- data/lib/ruby-prof/printers/abstract_printer.rb +73 -50
- data/lib/ruby-prof/printers/call_info_printer.rb +13 -3
- data/lib/ruby-prof/printers/call_stack_printer.rb +62 -145
- data/lib/ruby-prof/printers/call_tree_printer.rb +20 -12
- data/lib/ruby-prof/printers/dot_printer.rb +5 -5
- data/lib/ruby-prof/printers/flat_printer.rb +6 -24
- data/lib/ruby-prof/printers/graph_html_printer.rb +6 -192
- data/lib/ruby-prof/printers/graph_printer.rb +13 -15
- data/lib/ruby-prof/printers/multi_printer.rb +66 -23
- data/lib/ruby-prof/profile.rb +10 -3
- data/lib/ruby-prof/rack.rb +0 -3
- data/lib/ruby-prof/thread.rb +12 -12
- data/lib/ruby-prof/version.rb +1 -1
- data/ruby-prof.gemspec +2 -2
- data/test/abstract_printer_test.rb +0 -27
- data/test/alias_test.rb +129 -0
- data/test/basic_test.rb +41 -40
- data/test/call_info_visitor_test.rb +3 -3
- data/test/dynamic_method_test.rb +0 -2
- data/test/fiber_test.rb +11 -17
- data/test/gc_test.rb +96 -0
- data/test/line_number_test.rb +120 -39
- data/test/marshal_test.rb +119 -0
- data/test/measure_allocations.rb +30 -0
- data/test/measure_allocations_test.rb +371 -12
- data/test/measure_allocations_trace_test.rb +385 -0
- data/test/measure_memory_trace_test.rb +756 -0
- data/test/measure_process_time_test.rb +821 -33
- data/test/measure_times.rb +54 -0
- data/test/measure_wall_time_test.rb +349 -145
- data/test/multi_printer_test.rb +1 -34
- data/test/parser_timings.rb +24 -0
- data/test/pause_resume_test.rb +5 -5
- data/test/prime.rb +2 -0
- data/test/printer_call_stack_test.rb +28 -0
- data/test/printer_call_tree_test.rb +31 -0
- data/test/printer_flat_test.rb +68 -0
- data/test/printer_graph_html_test.rb +60 -0
- data/test/printer_graph_test.rb +41 -0
- data/test/printers_test.rb +32 -166
- data/test/printing_recursive_graph_test.rb +26 -72
- data/test/recursive_test.rb +72 -77
- data/test/stack_printer_test.rb +2 -15
- data/test/start_stop_test.rb +22 -25
- data/test/test_helper.rb +5 -248
- data/test/thread_test.rb +11 -54
- data/test/unique_call_path_test.rb +16 -28
- data/test/yarv_test.rb +1 -0
- metadata +28 -36
- data/examples/flat.txt +0 -50
- data/examples/graph.dot +0 -84
- data/examples/graph.html +0 -823
- data/examples/graph.txt +0 -139
- data/examples/multi.flat.txt +0 -23
- data/examples/multi.graph.html +0 -760
- data/examples/multi.grind.dat +0 -114
- data/examples/multi.stack.html +0 -547
- data/examples/stack.html +0 -547
- data/ext/ruby_prof/rp_measure.c +0 -40
- data/ext/ruby_prof/rp_measure.h +0 -45
- data/ext/ruby_prof/rp_measure_cpu_time.c +0 -136
- data/ext/ruby_prof/rp_measure_gc_runs.c +0 -73
- data/ext/ruby_prof/rp_measure_gc_time.c +0 -60
- data/lib/ruby-prof/aggregate_call_info.rb +0 -76
- data/lib/ruby-prof/assets/call_stack_printer.css.html +0 -117
- data/lib/ruby-prof/assets/call_stack_printer.js.html +0 -385
- data/lib/ruby-prof/printers/flat_printer_with_line_numbers.rb +0 -83
- data/lib/ruby-prof/profile/exclude_common_methods.rb +0 -207
- data/lib/ruby-prof/profile/legacy_method_elimination.rb +0 -50
- data/test/aggregate_test.rb +0 -136
- data/test/block_test.rb +0 -74
- data/test/call_info_test.rb +0 -78
- data/test/issue137_test.rb +0 -63
- data/test/measure_cpu_time_test.rb +0 -212
- data/test/measure_gc_runs_test.rb +0 -32
- data/test/measure_gc_time_test.rb +0 -36
- data/test/measure_memory_test.rb +0 -33
- data/test/method_elimination_test.rb +0 -84
- data/test/module_test.rb +0 -45
- data/test/stack_test.rb +0 -138
@@ -5,14 +5,25 @@ require 'thread'
|
|
5
5
|
require 'fileutils'
|
6
6
|
|
7
7
|
module RubyProf
|
8
|
-
#
|
8
|
+
# Generates profiling information in callgrind format for use by
|
9
9
|
# kcachegrind and similar tools.
|
10
|
-
#
|
11
|
-
# Note: when profiling for a callgrind printer, one should use the
|
12
|
-
# merge_fibers: true option when creating the profile. Otherwise
|
13
|
-
# each fiber would appear as a separate profile.
|
14
10
|
|
15
11
|
class CallTreePrinter < AbstractPrinter
|
12
|
+
def calltree_name(method_info)
|
13
|
+
klass_path = method_info.klass_name.gsub("::", '/')
|
14
|
+
result = "#{klass_path}::#{method_info.method_name}"
|
15
|
+
|
16
|
+
case method_info.klass_flags
|
17
|
+
when 0x2
|
18
|
+
"#{result}^"
|
19
|
+
when 0x4
|
20
|
+
"#{result}^"
|
21
|
+
when 0x8
|
22
|
+
"#{result}*"
|
23
|
+
else
|
24
|
+
result
|
25
|
+
end
|
26
|
+
end
|
16
27
|
|
17
28
|
def determine_event_specification_and_value_scale
|
18
29
|
@event_specification = "events: "
|
@@ -23,9 +34,6 @@ module RubyProf
|
|
23
34
|
when RubyProf::WALL_TIME
|
24
35
|
@value_scale = 1_000_000
|
25
36
|
@event_specification << 'wall_time'
|
26
|
-
when RubyProf.const_defined?(:CPU_TIME) && RubyProf::CPU_TIME
|
27
|
-
@value_scale = RubyProf.cpu_frequency
|
28
|
-
@event_specification << 'cpu_time'
|
29
37
|
when RubyProf.const_defined?(:ALLOCATIONS) && RubyProf::ALLOCATIONS
|
30
38
|
@value_scale = 1
|
31
39
|
@event_specification << 'allocations'
|
@@ -72,7 +80,7 @@ module RubyProf
|
|
72
80
|
end
|
73
81
|
|
74
82
|
def file(method)
|
75
|
-
File.expand_path(method.source_file)
|
83
|
+
method.source_file ? File.expand_path(method.source_file) : ''
|
76
84
|
end
|
77
85
|
|
78
86
|
def print_thread(thread)
|
@@ -123,15 +131,15 @@ module RubyProf
|
|
123
131
|
def print_method(output, method)
|
124
132
|
# Print out the file and method name
|
125
133
|
output << "fl=#{file(method)}\n"
|
126
|
-
output << "fn=#{
|
134
|
+
output << "fn=#{self.calltree_name(method)}\n"
|
127
135
|
|
128
136
|
# Now print out the function line number and its self time
|
129
137
|
output << "#{method.line} #{convert(method.self_time)}\n"
|
130
138
|
|
131
139
|
# Now print out all the children methods
|
132
|
-
method.
|
140
|
+
method.callees.each do |callee|
|
133
141
|
output << "cfl=#{file(callee.target)}\n"
|
134
|
-
output << "cfn=#{callee.target
|
142
|
+
output << "cfn=#{self.calltree_name(callee.target)}\n"
|
135
143
|
output << "calls=#{callee.called} #{callee.line}\n"
|
136
144
|
|
137
145
|
# Print out total times here!
|
@@ -4,6 +4,7 @@ require 'set'
|
|
4
4
|
|
5
5
|
module RubyProf
|
6
6
|
# Generates a graphviz graph in dot format.
|
7
|
+
#
|
7
8
|
# To use the dot printer:
|
8
9
|
#
|
9
10
|
# result = RubyProf.profile do
|
@@ -84,7 +85,7 @@ module RubyProf
|
|
84
85
|
total_percentage = (method.total_time/total_time) * 100
|
85
86
|
|
86
87
|
next if total_percentage < min_percent
|
87
|
-
name =
|
88
|
+
name = method.full_name.split("#").last
|
88
89
|
puts "#{dot_id(method)} [label=\"#{name}\\n(#{total_percentage.round}%)\"];"
|
89
90
|
@seen_methods << method
|
90
91
|
print_edges(total_time, method)
|
@@ -113,13 +114,12 @@ module RubyProf
|
|
113
114
|
end
|
114
115
|
|
115
116
|
def print_edges(total_time, method)
|
116
|
-
method.
|
117
|
-
|
118
|
-
target_percentage = (child.target.total_time / total_time) * 100.0
|
117
|
+
method.callers.sort_by(&:total_time).reverse.each do |call_info|
|
118
|
+
target_percentage = (call_info.target.total_time / total_time) * 100.0
|
119
119
|
next if target_percentage < min_percent
|
120
120
|
|
121
121
|
# Get children method
|
122
|
-
puts "#{dot_id(method)} -> #{dot_id(
|
122
|
+
puts "#{dot_id(method)} -> #{dot_id(call_info.target)} [label=\"#{call_info.called}/#{call_info.target.called}\" fontsize=10 fontcolor=#{EDGE_COLOR}];"
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
@@ -19,21 +19,8 @@ module RubyProf
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
# print_thread(thread)
|
25
|
-
# @output << "\n" * 2
|
26
|
-
# end
|
27
|
-
#end
|
28
|
-
|
29
|
-
def print_header(thread)
|
30
|
-
@output << "Measure Mode: %s\n" % RubyProf.measure_mode_string
|
31
|
-
@output << "Thread ID: %d\n" % thread.id
|
32
|
-
@output << "Fiber ID: %d\n" % thread.fiber_id unless thread.id == thread.fiber_id
|
33
|
-
@output << "Total: %0.6f\n" % thread.total_time
|
34
|
-
@output << "Sort by: #{sort_method}\n"
|
35
|
-
@output << "\n"
|
36
|
-
@output << " %self total self wait child calls name\n"
|
22
|
+
def print_column_headers
|
23
|
+
@output << " %self total self wait child calls name location\n"
|
37
24
|
end
|
38
25
|
|
39
26
|
def print_methods(thread)
|
@@ -49,7 +36,7 @@ module RubyProf
|
|
49
36
|
#self_time_called = method.called > 0 ? method.self_time/method.called : 0
|
50
37
|
#total_time_called = method.called > 0? method.total_time/method.called : 0
|
51
38
|
|
52
|
-
@output << "%6.2f %9.3f %9.3f %9.3f %9.3f %8d %s%s\n" % [
|
39
|
+
@output << "%6.2f %9.3f %9.3f %9.3f %9.3f %8d %s%-30s %s\n" % [
|
53
40
|
method.self_time / total_time * 100, # %self
|
54
41
|
method.total_time, # total
|
55
42
|
method.self_time, # self
|
@@ -57,14 +44,9 @@ module RubyProf
|
|
57
44
|
method.children_time, # children
|
58
45
|
method.called, # calls
|
59
46
|
method.recursive? ? "*" : " ", # cycle
|
60
|
-
|
61
|
-
|
47
|
+
method.full_name, # method_name]
|
48
|
+
method_location(method)] # location]
|
62
49
|
end
|
63
50
|
end
|
64
|
-
|
65
|
-
def print_footer(thread)
|
66
|
-
@output << "\n"
|
67
|
-
@output << "* indicates recursively called methods\n"
|
68
|
-
end
|
69
51
|
end
|
70
|
-
end
|
52
|
+
end
|
@@ -14,33 +14,18 @@ module RubyProf
|
|
14
14
|
# printer.print(STDOUT, :min_percent=>0)
|
15
15
|
#
|
16
16
|
# The Graph printer takes the following options in its print methods:
|
17
|
-
# :filename - specify a file to use that contains the ERB
|
18
|
-
# template to use, instead of the built-in self.template
|
19
|
-
#
|
20
|
-
# :template - specify an ERB template to use, instead of the
|
21
|
-
# built-in self.template
|
22
|
-
#
|
23
|
-
# :editor_uri - Specifies editor uri scheme used for opening files
|
24
|
-
# e.g. :atm or :mvim. For OS X default is :txmt.
|
25
|
-
# Use RUBY_PROF_EDITOR_URI environment variable to overide.
|
26
17
|
|
27
18
|
class GraphHtmlPrinter < AbstractPrinter
|
28
19
|
include ERB::Util
|
29
20
|
|
30
21
|
def setup_options(options)
|
31
22
|
super(options)
|
32
|
-
|
33
|
-
filename = options[:filename]
|
34
|
-
template = filename ? File.read(filename).untaint : (options[:template] || self.template)
|
35
|
-
@erb = ERB.new(template)
|
36
|
-
@erb.filename = filename
|
23
|
+
@erb = ERB.new(self.template)
|
37
24
|
end
|
38
25
|
|
39
26
|
def print(output = STDOUT, options = {})
|
40
|
-
@output = output
|
41
27
|
setup_options(options)
|
42
|
-
|
43
|
-
@output << @erb.result(binding).split("\n").map(&:rstrip).join("\n") << "\n"
|
28
|
+
output << @erb.result(binding)
|
44
29
|
end
|
45
30
|
|
46
31
|
# Creates a link to a method. Note that we do not create
|
@@ -63,187 +48,16 @@ module RubyProf
|
|
63
48
|
end
|
64
49
|
|
65
50
|
def file_link(path, linenum)
|
66
|
-
|
67
|
-
if srcfile =~ /\/ruby_runtime$/
|
51
|
+
if path.nil?
|
68
52
|
""
|
69
53
|
else
|
70
|
-
|
71
|
-
|
72
|
-
"open?url=file://#{h srcfile}&line=#{linenum}\"" \
|
73
|
-
"title=\"#{h srcfile}:#{linenum}\">#{linenum}</a>"
|
74
|
-
else
|
75
|
-
"<a href=\"file://#{h srcfile}##{linenum}\" title=\"#{h srcfile}:#{linenum}\">#{linenum}</a>"
|
76
|
-
end
|
54
|
+
srcfile = File.expand_path(path)
|
55
|
+
"<a href=\"file://#{h srcfile}##{linenum}\" title=\"#{h srcfile}:#{linenum}\">#{linenum}</a>"
|
77
56
|
end
|
78
57
|
end
|
79
58
|
|
80
59
|
def template
|
81
|
-
'
|
82
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
83
|
-
<html>
|
84
|
-
<head>
|
85
|
-
<style media="all" type="text/css">
|
86
|
-
table {
|
87
|
-
border-collapse: collapse;
|
88
|
-
border: 1px solid #CCC;
|
89
|
-
font-family: Verdana, Arial, Helvetica, sans-serif;
|
90
|
-
font-size: 9pt;
|
91
|
-
line-height: normal;
|
92
|
-
width: 100%;
|
93
|
-
}
|
94
|
-
|
95
|
-
th {
|
96
|
-
text-align: center;
|
97
|
-
border-top: 1px solid #FB7A31;
|
98
|
-
border-bottom: 1px solid #FB7A31;
|
99
|
-
background: #FFC;
|
100
|
-
padding: 0.3em;
|
101
|
-
border-left: 1px solid silver;
|
102
|
-
}
|
103
|
-
|
104
|
-
tr.break td {
|
105
|
-
border: 0;
|
106
|
-
border-top: 1px solid #FB7A31;
|
107
|
-
padding: 0;
|
108
|
-
margin: 0;
|
109
|
-
}
|
110
|
-
|
111
|
-
tr.method td {
|
112
|
-
font-weight: bold;
|
113
|
-
}
|
114
|
-
|
115
|
-
td {
|
116
|
-
padding: 0.3em;
|
117
|
-
}
|
118
|
-
|
119
|
-
td:first-child {
|
120
|
-
width: 190px;
|
121
|
-
}
|
122
|
-
|
123
|
-
td {
|
124
|
-
border-left: 1px solid #CCC;
|
125
|
-
text-align: center;
|
126
|
-
}
|
127
|
-
|
128
|
-
.method_name {
|
129
|
-
text-align: left;
|
130
|
-
}
|
131
|
-
|
132
|
-
tfoot td {
|
133
|
-
text-align: left;
|
134
|
-
}
|
135
|
-
</style>
|
136
|
-
</head>
|
137
|
-
<body>
|
138
|
-
<h1>Profile Report: <%= RubyProf.measure_mode_string %></h1>
|
139
|
-
<!-- Threads Table -->
|
140
|
-
<table>
|
141
|
-
<tr>
|
142
|
-
<th>Thread ID</th>
|
143
|
-
<th>Fiber ID</th>
|
144
|
-
<th>Total Time</th>
|
145
|
-
</tr>
|
146
|
-
<% for thread in @result.threads %>
|
147
|
-
<tr>
|
148
|
-
<td><%= thread.id %></td>
|
149
|
-
<td><a href="#<%= thread.fiber_id %>"><%= thread.fiber_id %></a></td>
|
150
|
-
<td><%= thread.total_time %></td>
|
151
|
-
</tr>
|
152
|
-
<% end %>
|
153
|
-
</table>
|
154
|
-
<!-- Methods Tables -->
|
155
|
-
<%
|
156
|
-
for thread in @result.threads
|
157
|
-
methods = thread.methods
|
158
|
-
total_time = thread.total_time
|
159
|
-
%>
|
160
|
-
<h2><a name="<%= thread.fiber_id %>">Thread <%= thread.id %>, Fiber: <%= thread.fiber_id %></a></h2>
|
161
|
-
<table>
|
162
|
-
<thead>
|
163
|
-
<tr>
|
164
|
-
<th>%Total</th>
|
165
|
-
<th>%Self</th>
|
166
|
-
<th>Total</th>
|
167
|
-
<th>Self</th>
|
168
|
-
<th>Wait</th>
|
169
|
-
<th>Child</th>
|
170
|
-
<th>Calls</th>
|
171
|
-
<th class="method_name">Name</th>
|
172
|
-
<th>Line</th>
|
173
|
-
</tr>
|
174
|
-
</thead>
|
175
|
-
<tbody>
|
176
|
-
<%
|
177
|
-
min_time = @options[:min_time] || (@options[:nonzero] ? 0.005 : nil)
|
178
|
-
methods.sort_by(&sort_method).reverse_each do |method|
|
179
|
-
total_percentage = (method.total_time/total_time) * 100
|
180
|
-
next if total_percentage < min_percent
|
181
|
-
next if min_time && method.total_time < min_time
|
182
|
-
self_percentage = (method.self_time/total_time) * 100
|
183
|
-
%>
|
184
|
-
<!-- Parents -->
|
185
|
-
<%
|
186
|
-
for caller in method.aggregate_parents.sort_by(&:total_time)
|
187
|
-
next unless caller.parent
|
188
|
-
next if min_time && caller.total_time < min_time
|
189
|
-
%>
|
190
|
-
<tr>
|
191
|
-
<td> </td>
|
192
|
-
<td> </td>
|
193
|
-
<td><%= sprintf("%.2f", caller.total_time) %></td>
|
194
|
-
<td><%= sprintf("%.2f", caller.self_time) %></td>
|
195
|
-
<td><%= sprintf("%.2f", caller.wait_time) %></td>
|
196
|
-
<td><%= sprintf("%.2f", caller.children_time) %></td>
|
197
|
-
<td><%= "#{caller.called}/#{method.called}" %></td>
|
198
|
-
<td class="method_name"><%= create_link(thread, total_time, caller.parent.target) %></td>
|
199
|
-
<td><%= file_link(caller.parent.target.source_file, caller.line) %></td>
|
200
|
-
</tr>
|
201
|
-
<% end %>
|
202
|
-
<tr class="method">
|
203
|
-
<td><%= sprintf("%.2f%%", total_percentage) %></td>
|
204
|
-
<td><%= sprintf("%.2f%%", self_percentage) %></td>
|
205
|
-
<td><%= sprintf("%.2f", method.total_time) %></td>
|
206
|
-
<td><%= sprintf("%.2f", method.self_time) %></td>
|
207
|
-
<td><%= sprintf("%.2f", method.wait_time) %></td>
|
208
|
-
<td><%= sprintf("%.2f", method.children_time) %></td>
|
209
|
-
<td><%= sprintf("%i", method.called) %></td>
|
210
|
-
<td class="method_name">
|
211
|
-
<a name="<%= method_href(thread, method) %>">
|
212
|
-
<%= method.recursive? ? "*" : " "%><%= h method.full_name %>
|
213
|
-
</a>
|
214
|
-
</td>
|
215
|
-
<td><%= file_link(method.source_file, method.line) %></td>
|
216
|
-
</tr>
|
217
|
-
<!-- Children -->
|
218
|
-
<%
|
219
|
-
for callee in method.aggregate_children.sort_by(&:total_time).reverse
|
220
|
-
next if min_time && callee.total_time < min_time
|
221
|
-
%>
|
222
|
-
<tr>
|
223
|
-
<td> </td>
|
224
|
-
<td> </td>
|
225
|
-
<td><%= sprintf("%.2f", callee.total_time) %></td>
|
226
|
-
<td><%= sprintf("%.2f", callee.self_time) %></td>
|
227
|
-
<td><%= sprintf("%.2f", callee.wait_time) %></td>
|
228
|
-
<td><%= sprintf("%.2f", callee.children_time) %></td>
|
229
|
-
<td><%= "#{callee.called}/#{callee.target.called}" %></td>
|
230
|
-
<td class="method_name"><%= create_link(thread, total_time, callee.target) %></td>
|
231
|
-
<td><%= file_link(method.source_file, callee.line) %></td>
|
232
|
-
</tr>
|
233
|
-
<% end %>
|
234
|
-
<!-- Create divider row -->
|
235
|
-
<tr class="break"><td colspan="9"></td></tr>
|
236
|
-
<% end %>
|
237
|
-
</tbody>
|
238
|
-
<tfoot>
|
239
|
-
<tr>
|
240
|
-
<td colspan="9">* indicates recursively called methods</td>
|
241
|
-
</tr>
|
242
|
-
</tfoot>
|
243
|
-
</table>
|
244
|
-
<% end %>
|
245
|
-
</body>
|
246
|
-
</html>'
|
60
|
+
open_asset('graph_printer.html.erb')
|
247
61
|
end
|
248
62
|
end
|
249
63
|
end
|
@@ -20,10 +20,14 @@ module RubyProf
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
+
def sort_method
|
24
|
+
@options[:sort_method] || :total_time
|
25
|
+
end
|
26
|
+
|
23
27
|
def print_header(thread)
|
24
28
|
@output << "Measure Mode: %s\n" % RubyProf.measure_mode_string
|
25
29
|
@output << "Thread ID: #{thread.id}\n"
|
26
|
-
@output << "Fiber ID: #{thread.fiber_id}\n"
|
30
|
+
@output << "Fiber ID: #{thread.fiber_id}\n"
|
27
31
|
@output << "Total Time: #{thread.total_time}\n"
|
28
32
|
@output << "Sort by: #{sort_method}\n"
|
29
33
|
@output << "\n"
|
@@ -37,6 +41,7 @@ module RubyProf
|
|
37
41
|
@output << sprintf("%#{TIME_WIDTH}s", "child")
|
38
42
|
@output << sprintf("%#{CALL_WIDTH}s", "calls")
|
39
43
|
@output << " name"
|
44
|
+
@output << " location"
|
40
45
|
@output << "\n"
|
41
46
|
end
|
42
47
|
|
@@ -52,7 +57,7 @@ module RubyProf
|
|
52
57
|
|
53
58
|
self_percentage = (method.self_time/total_time) * 100
|
54
59
|
|
55
|
-
@output << "-" *
|
60
|
+
@output << "-" * 150 << "\n"
|
56
61
|
print_parents(thread, method)
|
57
62
|
|
58
63
|
# 1 is for % sign
|
@@ -64,10 +69,8 @@ module RubyProf
|
|
64
69
|
@output << sprintf("%#{TIME_WIDTH}.3f", method.children_time)
|
65
70
|
@output << sprintf("%#{CALL_WIDTH}i", method.called)
|
66
71
|
@output << sprintf(" %s", method.recursive? ? "*" : " ")
|
67
|
-
@output << sprintf("
|
68
|
-
|
69
|
-
@output << sprintf(" %s:%s", method.source_file, method.line)
|
70
|
-
end
|
72
|
+
@output << sprintf("%-30s", method.full_name)
|
73
|
+
@output << sprintf(" %s", method_location(method))
|
71
74
|
@output << "\n"
|
72
75
|
|
73
76
|
print_children(method)
|
@@ -75,8 +78,8 @@ module RubyProf
|
|
75
78
|
end
|
76
79
|
|
77
80
|
def print_parents(thread, method)
|
78
|
-
method.
|
79
|
-
|
81
|
+
return if method.root?
|
82
|
+
method.callers.sort_by(&:total_time).each do |caller|
|
80
83
|
@output << " " * 2 * PERCENTAGE_WIDTH
|
81
84
|
@output << sprintf("%#{TIME_WIDTH}.3f", caller.total_time)
|
82
85
|
@output << sprintf("%#{TIME_WIDTH}.3f", caller.self_time)
|
@@ -85,13 +88,13 @@ module RubyProf
|
|
85
88
|
|
86
89
|
call_called = "#{caller.called}/#{method.called}"
|
87
90
|
@output << sprintf("%#{CALL_WIDTH}s", call_called)
|
88
|
-
@output << sprintf(" %s", caller.parent.
|
91
|
+
@output << sprintf(" %s", caller.parent.full_name)
|
89
92
|
@output << "\n"
|
90
93
|
end
|
91
94
|
end
|
92
95
|
|
93
96
|
def print_children(method)
|
94
|
-
method.
|
97
|
+
method.callees.sort_by(&:total_time).reverse.each do |child|
|
95
98
|
# Get children method
|
96
99
|
|
97
100
|
@output << " " * 2 * PERCENTAGE_WIDTH
|
@@ -107,10 +110,5 @@ module RubyProf
|
|
107
110
|
@output << "\n"
|
108
111
|
end
|
109
112
|
end
|
110
|
-
|
111
|
-
def print_footer(thread)
|
112
|
-
@output << "\n"
|
113
|
-
@output << "* indicates recursively called methods\n"
|
114
|
-
end
|
115
113
|
end
|
116
114
|
end
|