Skip to content

Commit

Permalink
cmd/trace: skip links for buckets with 0 count
Browse files Browse the repository at this point in the history
Change-Id: Ib1c2f7cc8e8f631ed9e74161699332f492d4cb0d
Reviewed-on: https://go-review.googlesource.com/112196
Reviewed-by: Peter Weinberger <[email protected]>
  • Loading branch information
hyangah committed May 8, 2018
1 parent d96221f commit 9eface7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/cmd/trace/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,12 +861,16 @@ func (h *durationHistogram) ToHTML(urlmaker func(min, max time.Duration) string)
fmt.Fprintf(w, `<table>`)
for i := h.MinBucket; i <= h.MaxBucket; i++ {
// Tick label.
fmt.Fprintf(w, `<tr><td class="histoTime" align="right"><a href=%s>%s</a></td>`, urlmaker(h.BucketMin(i), h.BucketMin(i+1)), niceDuration(h.BucketMin(i)))
if h.Buckets[i] > 0 {
fmt.Fprintf(w, `<tr><td class="histoTime" align="right"><a href=%s>%s</a></td>`, urlmaker(h.BucketMin(i), h.BucketMin(i+1)), niceDuration(h.BucketMin(i)))
} else {
fmt.Fprintf(w, `<tr><td class="histoTime" align="right">%s</td>`, niceDuration(h.BucketMin(i)))
}
// Bucket bar.
width := h.Buckets[i] * barWidth / maxCount
fmt.Fprintf(w, `<td><div style="width:%dpx;background:blue;top:.6em;position:relative">&nbsp;</div></td>`, width)
fmt.Fprintf(w, `<td><div style="width:%dpx;background:blue;position:relative">&nbsp;</div></td>`, width)
// Bucket count.
fmt.Fprintf(w, `<td align="right"><div style="top:.6em;position:relative">%d</div></td>`, h.Buckets[i])
fmt.Fprintf(w, `<td align="right"><div style="position:relative">%d</div></td>`, h.Buckets[i])
fmt.Fprintf(w, "</tr>\n")

}
Expand Down

0 comments on commit 9eface7

Please sign in to comment.