Class: RubyProf::CallTreePrinter
Overview
Generate profiling information in calltree format for use by kcachegrind and similar tools.
Instance Method Summary
collapse
#initialize, #method_name, #min_percent, #print_file, #setup_options
Instance Method Details
#convert(value) ⇒ Object
42
43
44
|
# File 'lib/ruby-prof/call_tree_printer.rb', line 42
def convert(value)
(value * @value_scale).round
end
|
#file(method) ⇒ Object
46
47
48
|
# File 'lib/ruby-prof/call_tree_printer.rb', line 46
def file(method)
File.expand_path(method.source_file)
end
|
#name(method) ⇒ Object
50
51
52
|
# File 'lib/ruby-prof/call_tree_printer.rb', line 50
def name(method)
"#{method.klass_name}::#{method.method_name}"
end
|
#print(output = STDOUT, options = {}) ⇒ Object
#print_methods(thread_id, methods) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/ruby-prof/call_tree_printer.rb', line 54
def print_methods(thread_id, methods)
methods.reverse_each do |method|
@output << "fl=#{file(method)}\n"
@output << "fn=#{name(method)}\n"
@output << "#{method.line} #{convert(method.self_time)}\n"
method.children.each do |callee|
@output << "cfl=#{file(callee.target)}\n"
@output << "cfn=#{name(callee.target)}\n"
@output << "calls=#{callee.called} #{callee.line}\n"
@output << "#{callee.line} #{convert(callee.total_time)}\n"
end
@output << "\n"
end
end
|
#print_threads ⇒ Object
36
37
38
39
40
|
# File 'lib/ruby-prof/call_tree_printer.rb', line 36
def print_threads
@result.threads.each do |thread_id, methods|
print_methods(thread_id, methods)
end
end
|