From e7cbbbe9bb878b6ca4ce04fde645df1c8f1845bd Mon Sep 17 00:00:00 2001 From: Daniel Martí Date: Mon, 12 Feb 2018 16:34:48 +0000 Subject: cmd/vendor/github.com/google/pprof: refresh from upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updating to commit 0e0e5b7254e076a62326ab7305ba49e8515f0c91 from github.com/google/pprof Recent modifications to the vendored pprof, such as skipping TestWebInterface to avoid starting a web browser, have all been fixed upstream. Change-Id: I72e11108c438e1573bf2f9216e76d157378e8d45 Reviewed-on: https://go-review.googlesource.com/93375 Run-TryBot: Daniel Martí TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- .../google/pprof/internal/graph/dotgraph.go | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go') diff --git a/src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go b/src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go index 4e5d12f6cd..f3721e92f5 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go @@ -154,7 +154,7 @@ func (b *builder) addNode(node *Node, nodeID int, maxFlat float64) { if flat != 0 { label = label + fmt.Sprintf(`%s (%s)`, flatValue, - strings.TrimSpace(percentage(flat, b.config.Total))) + strings.TrimSpace(measurement.Percentage(flat, b.config.Total))) } else { label = label + "0" } @@ -168,7 +168,7 @@ func (b *builder) addNode(node *Node, nodeID int, maxFlat float64) { cumValue = b.config.FormatValue(cum) label = label + fmt.Sprintf(`of %s (%s)`, cumValue, - strings.TrimSpace(percentage(cum, b.config.Total))) + strings.TrimSpace(measurement.Percentage(cum, b.config.Total))) } // Scale font sizes from 8 to 24 based on percentage of flat frequency. @@ -380,23 +380,6 @@ func dotColor(score float64, isBackground bool) string { return fmt.Sprintf("#%02x%02x%02x", uint8(r*255.0), uint8(g*255.0), uint8(b*255.0)) } -// percentage computes the percentage of total of a value, and encodes -// it as a string. At least two digits of precision are printed. -func percentage(value, total int64) string { - var ratio float64 - if total != 0 { - ratio = math.Abs(float64(value)/float64(total)) * 100 - } - switch { - case math.Abs(ratio) >= 99.95 && math.Abs(ratio) <= 100.05: - return " 100%" - case math.Abs(ratio) >= 1.0: - return fmt.Sprintf("%5.2f%%", ratio) - default: - return fmt.Sprintf("%5.2g%%", ratio) - } -} - func multilinePrintableName(info *NodeInfo) string { infoCopy := *info infoCopy.Name = strings.Replace(infoCopy.Name, "::", `\n`, -1) -- cgit v1.3-5-g9baa