def print(output = STDOUT, options = {})
@output = output
setup_options(options)
if @graph_html = options.delete(:graph)
@graph_html = "file://" + @graph_html if @graph_html[0]=="/"
end
@overall_threads_time = 0.0
@threads_totals = Hash.new
@result.threads.each do |thread_id, methods|
roots = methods.select{|m| m.root?}
thread_total_time = sum(roots.map{|r| self.total_time(r.call_infos)})
@overall_threads_time += thread_total_time
@threads_totals[thread_id] = thread_total_time
end
print_header
@result.threads.keys.sort.each do |thread_id|
@current_thread_id = thread_id
@overall_time = @threads_totals[thread_id]
@output.print "<div class=\"thread\">Thread: #{thread_id} (#{"%4.2f%%" % ((@overall_time/@overall_threads_time)*100)} ~ #{@overall_time})</div>"
@output.print "<ul name=\"thread\">"
@result.threads[thread_id].each do |m|
next unless m.root?
m.call_infos.each do |ci|
next unless ci.root?
print_stack ci, @threads_totals[thread_id]
end
end
@output.print "</ul>"
end
print_footer
copy_image_files
end