ui/index.html.erb in stack_tracy-0.1.6 vs ui/index.html.erb in stack_tracy-0.1.7

- old
+ new

@@ -24,10 +24,13 @@ <a href="#stack_trace" data-toggle="tab">Stack trace</a> </li> <li> <a href="#cumulatives" data-toggle="tab">Cumulatives</a> </li> + <li> + <a href="#realtime_cumulatives" data-toggle="tab">Realtime cumulatives</a> + </li> </ul> <div class="tab-content"><% limited = events.size > limit threshold = nil unless limited || slows_only excluded_objects = if limited @@ -37,10 +40,11 @@ end comment_depth = nil last_depth = nil last_duration = nil corrections = [] + stack = [] cumulatives = {} %> <div class="tab-pane active" id="stack_trace"> <div class="head"> <span class="time">Time</span> <span class="duration">Duration</span> @@ -53,17 +57,27 @@ (excluded_objects.include?(event[:object]) || "#{event[:object]}".match(/^#/)) end if skip corrections.unshift event[:depth] if corrections.empty? || corrections.first != event[:depth] else - cumulatives[event[:call]] ||= {:duration => 0.0, :count => 0} - cumulatives[event[:call]][:duration] += event[:duration].to_f - cumulatives[event[:call]][:count] += 1 - cumulatives[event[:call]][:average] = cumulatives[event[:call]][:duration].to_f / cumulatives[event[:call]][:count].to_f + 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 %> <div class="group"><% if threshold && comment_depth.nil? && last_duration && last_duration < threshold %><% comment_depth = event[:depth] - corrections.size %><%= "\n<!--" %><% end %><% else close_tags = ((event[:depth] - corrections.size + 1)..last_depth.to_i).collect do |depth| if comment_depth && depth == comment_depth comment_depth = nil @@ -93,19 +107,35 @@ %><%= close_tags %> </div> </div> <div class="tab-pane" id="cumulatives"> <div class="head"> - <span class="average"><a href="javascript:StackTracy.sort(0)">Average</a></span> - <span class="duration"><a href="javascript:StackTracy.sort(1)">Duration</a></span> - <span class="count"><a href="javascript:StackTracy.sort(2)">Count</a></span> - <span class="call"><a href="javascript:StackTracy.sort(3)">Call</a></span> + <span class="average"><a href="javascript:StackTracy.sort('cumulatives', 0)">Average</a></span> + <span class="duration"><a href="javascript:StackTracy.sort('cumulatives', 1)">Duration</a></span> + <span class="count"><a href="javascript:StackTracy.sort('cumulatives', 2)">Count</a></span> + <span class="call"><a href="javascript:StackTracy.sort('cumulatives', 3)">Call</a></span> </div> <div class="body"><% cumulatives.sort{|(ak, av), (bk, bv)| bv[:average] <=> av[:average]}.each do |call, stats| %> <div> <span class="average" abbr="<%= "%.6f" % stats[:average] %>"><%= "%.6f" % stats[:average] %></span> <span class="duration" abbr="<%= "%.6f" % stats[:duration] %>"><%= "%.6f" % stats[:duration] %></span> <span class="count" abbr="<%= stats[:count] %>"><%= stats[:count] %></span> +<span class="call" abbr="<%= call.gsub("<", "&lt;").gsub(">", "&gt;") %>"><%= call.gsub("<", "&lt;").gsub(">", "&gt;").gsub(/^"(.*)"$/){ "<strong>#{$1}</strong>" } %></span> +</div><% end %> + </div> + </div> + <div class="tab-pane" id="realtime_cumulatives"> + <div class="head"> + <span class="average"><a href="javascript:StackTracy.sort('realtime_cumulatives', 0)">Average</a></span> + <span class="duration"><a href="javascript:StackTracy.sort('realtime_cumulatives', 1)">Duration</a></span> + <span class="count"><a href="javascript:StackTracy.sort('realtime_cumulatives', 2)">Count</a></span> + <span class="call"><a href="javascript:StackTracy.sort('realtime_cumulatives', 3)">Call</a></span> + </div> + <div class="body"><% cumulatives.sort{|(ak, av), (bk, bv)| bv[:real_average] <=> av[:real_average]}.each do |call, stats| %> +<div> +<span class="average" abbr="<%= "%.6f" % stats[:real_average] %>"><%= "%.6f" % stats[:real_average] %></span> +<span class="duration" abbr="<%= "%.6f" % stats[:real_duration] %>"><%= "%.6f" % stats[:real_duration] %></span> +<span class="count" abbr="<%= stats[:real_count] %>"><%= stats[:real_count] %></span> <span class="call" abbr="<%= call.gsub("<", "&lt;").gsub(">", "&gt;") %>"><%= call.gsub("<", "&lt;").gsub(">", "&gt;").gsub(/^"(.*)"$/){ "<strong>#{$1}</strong>" } %></span> </div><% end %> </div> </div> </div> \ No newline at end of file