Commit e95bb831 authored by Austin Clements's avatar Austin Clements

benchstat: don't print geomean of just one benchmark

If there's just one benchmark, the geomean will be the same as the
benchmark result. Omit it.

Change-Id: Id165fa127aa8615015511d6a1da6e1be48b85539
Reviewed-on: https://go-review.googlesource.com/38093Reviewed-by: default avatarQuentin Smith <quentin@golang.org>
parent bb8119dd
......@@ -137,6 +137,7 @@ func addGeomean(c *Collection, t *Table, unit string, delta bool) {
row := &Row{Benchmark: "[Geo mean]"}
key := Key{Unit: unit}
geomeans := []float64{}
maxCount := 0
for _, key.Config = range c.Configs {
var means []float64
for _, key.Benchmark = range c.Benchmarks {
......@@ -151,6 +152,9 @@ func addGeomean(c *Collection, t *Table, unit string, delta bool) {
means = append(means, m.Mean)
}
}
if len(means) > maxCount {
maxCount = len(means)
}
if len(means) == 0 {
row.Metrics = append(row.Metrics, new(Metrics))
delta = false
......@@ -166,6 +170,12 @@ func addGeomean(c *Collection, t *Table, unit string, delta bool) {
})
}
}
if maxCount <= 1 {
// Only one benchmark contributed to this geomean.
// Since the geomean is the same as the benchmark
// result, don't bother outputting it.
return
}
if delta {
row.Delta = fmt.Sprintf("%+.2f%%", ((geomeans[1]/geomeans[0])-1.0)*100.0)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment