StackTracy  <%= file %>

<% limited = events.size > limit threshold = nil unless limited || slows_only excluded_objects = if limited %w(Array BasicObject Enumerable Fixnum Float Hash IO Integer Kernel Module Mutex Numeric Object Rational String Symbol Thread Time) else [] end comment_depth = nil last_depth = nil last_duration = nil corrections = [] stack = [] cumulatives = {} %>
Time Duration Call
<% events.each_with_index do |event, index| skip = begin ((event[:call][0] != "\"") && (messages_only || (slows_only && threshold && event[:duration] < threshold))) || (excluded_objects.include?(event[:object]) || "#{event[:object]}".match(/^#/)) end if skip corrections.unshift event[:depth] if corrections.empty? || corrections.first != event[:depth] else cumulative = (cumulatives[event[:call]] ||= {:duration => 0.0, :count => 0, :real_duration => 0.0, :real_count => 0}) cumulative[:duration] += event[:duration].to_f cumulative[:count] += 1 cumulative[:average] = cumulative[:duration].to_f / cumulative[:count].to_f corrections.size.times do |i| event[:depth] <= corrections[0] ? corrections.shift : break end stack = stack[0, event[:depth] - corrections.size] unless stack.include? event[:call] cumulative[:real_duration] += event[:duration].to_f cumulative[:real_count] += 1 cumulative[:real_average] = cumulative[:real_duration].to_f / cumulative[:real_count].to_f end stack << event[:call] if last_depth.to_i < event[:depth] - corrections.size %>
<% if threshold && comment_depth.nil? && last_duration && last_duration < threshold %><% comment_depth = event[:depth] - corrections.size %><%= "\n\n
" else "\n
" end end.reverse.join("") %><%= close_tags %><% end %>
<%= "%.6f" % event[:time] %> <%= event[:duration] ? ("%.6f" % event[:duration]) : "?" %> <% if (next_event = events[index + 1]) && next_event[:depth] > event[:depth] %><%= event[:call].gsub(/^"(.*)"$/){ "#{$1}" } %><% else %><%= event[:call].gsub(/^"(.*)"$/){ "#{$1}" } %><% end %>
<% last_depth = event[:depth] - corrections.size last_duration = event[:duration] end end close_tags = (1..last_depth.to_i).collect do |depth| if comment_depth && depth == comment_depth comment_depth = nil "\n-->\n
" else "\n
" end end.reverse.join("") %><%= close_tags %>
Average Duration Count Call
<% cumulatives.sort{|(ak, av), (bk, bv)| bv[:average] <=> av[:average]}.each do |call, stats| %>
"><%= "%.6f" % stats[:average] %> "><%= "%.6f" % stats[:duration] %> <%= stats[:count] %> ", ">") %>"><%= call.gsub("<", "<").gsub(">", ">").gsub(/^"(.*)"$/){ "#{$1}" } %>
<% end %>
Average Duration Count Call
<% cumulatives.sort{|(ak, av), (bk, bv)| bv[:real_average] <=> av[:real_average]}.each do |call, stats| %>
"><%= "%.6f" % stats[:real_average] %> "><%= "%.6f" % stats[:real_duration] %> <%= stats[:real_count] %> ", ">") %>"><%= call.gsub("<", "<").gsub(">", ">").gsub(/^"(.*)"$/){ "#{$1}" } %>
<% end %>