ui/index.html.erb in stack_tracy-0.1.3 vs ui/index.html.erb in stack_tracy-0.1.4

- old
+ new

@@ -6,10 +6,11 @@ stack_tracy@localhost: /<%= File.basename(file) if file %> </title> <script src="assets/jquery.js" type="text/javascript"></script> <script src="assets/bootstrap-tab.js" type="text/javascript"></script> <script src="assets/tiny_sort.js" type="text/javascript"></script> + <script src="assets/comments.js" type="text/javascript"></script> <script src="assets/stack_tracy.js" type="text/javascript"></script> <link href="assets/bootstrap-tab.css" type="text/css" rel="stylesheet" media="screen"/> <link href="assets/stack_tracy.css" type="text/css" rel="stylesheet" media="screen"/> </head> <body> @@ -24,94 +25,86 @@ </li> <li> <a href="#cumulatives" data-toggle="tab">Cumulatives</a> </li> </ul> - <div class="tab-content"> - <% - current_depth = 0 - excluded_objects = if events.size > 7500 - %w(Array BasicObject Enumerable Fixnum Float Hash IO Kernel Module Mutex Numeric Object Rational String Symbol Thread Time) - else - [] - end - corrections = [] - cumulatives = {} - %> + <div class="tab-content"><% + limited = events.size > limit + threshold = nil unless limited + 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 = [] + cumulatives = {} %> <div class="tab-pane active" id="stack_trace"> <div class="head"> <span class="time">Time</span> <span class="duration">Duration</span> <span class="call">Call</span> </div> - <div class="body"> - <% events.each_with_index do |event, index| %> - <% + <div class="body"><% + events.each_with_index do |event, index| skip = excluded_objects.include?(event[:object]) || "#{event[:object]}".match(/^#/) 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 corrections.size.times do |i| event[:depth] <= corrections[0] ? corrections.shift : break end - %> - <% if skip %> - <% corrections.unshift event[:depth] if corrections.empty? || corrections.first != event[:depth] %> - <% else %> - <% if current_depth < event[:depth] - corrections.size %> - <div class="group"> - <% elsif current_depth > event[:depth] - corrections.size %> - <%= "</div>" * (current_depth - (event[:depth] - corrections.size)) %> - <% end %> - <div> - <span class="time"> - <%= "%.6f" % event[:time] %> - </span> - <span class="duration"> - <%= event[:duration] ? ("%.6f" % event[:duration]) : "?" %> - </span> - <span class="call"> - <%= "&nbsp;&nbsp;&nbsp;" * (event[:depth] - corrections.size) %> - <% if (next_event = events[index + 1]) && next_event[:depth] > event[:depth] %> - <a class="toggler" href="#" onclick="return false"> - <%= event[:call] %> - </a> - <% else %> - <%= event[:call] %> - <% end %> - </span> - </div> - <% current_depth = event[:depth] - corrections.size %> - <% end %> - <% end %> - <%= "</div>" * current_depth %> +if skip +corrections.unshift event[:depth] if corrections.empty? || corrections.first != event[:depth] +else +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 + "\n-->\n</div>" + else + "\n</div>" + end +end.reverse.join("") +%><%= close_tags %><% end %> +<div> +<span class="time"><%= "%.6f" % event[:time] %></span> +<span class="duration"><%= event[:duration] ? ("%.6f" % event[:duration]) : "?" %></span> +<span style="padding-left: <%= 10 * (event[:depth] - corrections.size) %>px"><% if (next_event = events[index + 1]) && next_event[:depth] > event[:depth] %><a class="toggler" href="#" onclick="return false"><%= event[:call] %></a><% else %><%= event[:call] %><% end %></span> +</div><% +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</div>" + else + "\n</div>" + end +end.reverse.join("") +%><%= 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> </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;") %> - </span> - </div> - <% end %> + <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;") %></span> +</div><% end %> </div> </div> </div> </div> </div> \ No newline at end of file