1
0
mirror of https://github.com/golang/go synced 2024-11-05 11:46:12 -07:00

cmd/trace: use strings.Builder

Change-Id: I690dc517c08be4cd66439baad8b91f16622ff0d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/428292
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
cuiweixie 2022-09-04 20:14:47 +08:00 committed by Gopher Robot
parent c263fa07b1
commit e5ed2212a3

View File

@ -370,7 +370,7 @@ func (task *taskDesc) String() string {
if task == nil { if task == nil {
return "task <nil>" return "task <nil>"
} }
wb := new(bytes.Buffer) wb := new(strings.Builder)
fmt.Fprintf(wb, "task %d:\t%s\n", task.id, task.name) fmt.Fprintf(wb, "task %d:\t%s\n", task.id, task.name)
fmt.Fprintf(wb, "\tstart: %v end: %v complete: %t\n", task.firstTimestamp(), task.endTimestamp(), task.complete()) fmt.Fprintf(wb, "\tstart: %v end: %v complete: %t\n", task.firstTimestamp(), task.endTimestamp(), task.complete())
fmt.Fprintf(wb, "\t%d goroutines\n", len(task.goroutines)) fmt.Fprintf(wb, "\t%d goroutines\n", len(task.goroutines))
@ -872,7 +872,7 @@ func (h *durationHistogram) ToHTML(urlmaker func(min, max time.Duration) string)
} }
} }
w := new(bytes.Buffer) w := new(strings.Builder)
fmt.Fprintf(w, `<table>`) fmt.Fprintf(w, `<table>`)
for i := h.MinBucket; i <= h.MaxBucket; i++ { for i := h.MinBucket; i <= h.MaxBucket; i++ {
// Tick label. // Tick label.
@ -914,7 +914,7 @@ func (h *durationHistogram) String() string {
} }
} }
w := new(bytes.Buffer) w := new(strings.Builder)
for i := h.MinBucket; i <= h.MaxBucket; i++ { for i := h.MinBucket; i <= h.MaxBucket; i++ {
count := h.Buckets[i] count := h.Buckets[i]
bar := count * barWidth / maxCount bar := count * barWidth / maxCount