def print_methods(thread_id, methods)
toplevel = methods.max
total_time = toplevel.total_time
if total_time == 0
total_time = 0.01
end
methods = methods.sort do |m1, m2|
m1.self_time <=> m2.self_time
end.reverse
@output << "Thread ID: %d\n" % thread_id
@output << "Total: %0.6f\n" % total_time
@output << "\n"
@output << " %self total self wait child calls name\n"
sum = 0
methods.each do |method|
self_percent = (method.self_time / total_time) * 100
next if self_percent < min_percent
sum += method.self_time
@output << "%6.2f %8.2f %8.2f %8.2f %8.2f %8d %s " % [
method.self_time / total_time * 100,
method.total_time,
method.self_time,
method.wait_time,
method.children_time,
method.called,
method_name(method),
]
if method.source_file != 'ruby_runtime'
@output << " %s:%s" % [File.expand_path(method.source_file), method.line]
end
@output << "\n\tcalled from: "
method.call_infos.map{|ci|
if ci.parent && ci.parent.target.source_file != 'ruby_runtime'
[method_name(ci.parent.target), File.expand_path(ci.parent.target.source_file), ci.parent.target.line]
else
nil
end
}.compact.uniq.each{|args|
@output << " %s (%s:%s) " % args
}
@output << "\n\n"
end
end