Class: JRubyProf::TreeHtmlPrinter
Constant Summary
collapse
<<HTML
<html>
<body>
<head>
<style media="all" type="text/css">
table {
border-collapse: collapse;
border: 1px solid #CCC;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
line-height: normal;
}
th {
text-align: center;
border-top: 1px solid #339;
border-bottom: 1px solid #339;
background: #CDF;
padding: 0.3em;
border-left: 1px solid silver;
}
tr.break td {
border: 0;
border-top: 1px solid #339;
padding: 0;
margin: 0;
}
tr.method td {
font-weight: bold;
}
td {
padding: 0.3em;
}
td:first-child {
width: 190px;
}
td {
border-left: 1px solid #CCC;
text-align: center;
}
</style>
</head>
HTML
<<-HTML
<table>
<tr>
<th>%total</th>
<th>%self</th>
<th>total</th>
<th>self</th>
<th>children</th>
<th>calls</th>
<th>Name</th>
</tr>
HTML
<<HTML
</table>
<br />
<br />
HTML
<<-HTML
</body>
</html>
HTML
Instance Attribute Summary
#thread_set
Instance Method Summary
collapse
#initialize, #print_to_file
Instance Method Details
#get_invocations(arr, invocation) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/jruby-prof/tree_html_printer.rb', line 43
def get_invocations(arr, invocation)
arr << invocation
invocation.children.each do |inv|
get_invocations(arr, inv)
end
end
|
#print_invocation(output, invocation, total_duration, major_row) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/jruby-prof/tree_html_printer.rb', line 50
def print_invocation(output, invocation, total_duration, major_row)
next if invocation.name =~ /JRubyProf\.stop/
method = invocation.to_method
total = method.duration
total_pc = (total.to_f/total_duration)*100
children = method.childrens_duration
self_ = total - children
self_pc = (self_.to_f/total_duration)*100
calls = method.count
name = method.name
inv_id = invocation.id
template = File.read(File.join(File.dirname(__FILE__), "..", "..", "templates", "graph_row.html.erb"))
erb = ERB.new(template)
output.puts(erb.result(binding))
end
|
#print_on(output) ⇒ Object
4
5
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
33
34
35
36
37
38
39
40
41
|
# File 'lib/jruby-prof/tree_html_printer.rb', line 4
def print_on(output)
total_duration = thread_set.duration
output.puts HEADER
thread_set.invocations.each_with_index do |invocation, i|
all_invocations = []
get_invocations(all_invocations, invocation)
output.puts "<h3>Thread #{i + 1}/#{thread_set.length}</h3>"
output.puts TABLE_HEADER
all_invocations = all_invocations.sort_by {|i| m = i.to_method.duration }.reverse
all_invocations.each do |inv|
next if inv.name =~ /CachingCallSite\.stop_tracing/
next if inv.name =~ /JRubyProf\.stop/
next if inv.duration < 5
c = inv
parents = []
while c.parent
c = c.parent
parents << c
end
parents.reverse.each do |parent_inv|
print_invocation(output, parent_inv, total_duration, false)
end
print_invocation(output, inv, total_duration, true)
inv.children.each do |child_inv|
next if child_inv.name =~ /CachingCallSite\.stop_tracing/
print_invocation(output, child_inv, total_duration, false)
end
output.puts <<-HTML
<tr class="break">
<td colspan="7"></td>
</tr>
HTML
end
output.puts TABLE_FOOTER
end
output.puts FOOTER
end
|
#safe_name(name) ⇒ Object
66
67
68
|
# File 'lib/jruby-prof/tree_html_printer.rb', line 66
def safe_name(name)
name.gsub("#", "_inst_").gsub(".", "_stat_")
end
|