aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go')
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/graph/dotgraph.go21
1 files changed, 2 insertions, 19 deletions
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)