Commit ae5bfa61 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

benchstat: don't print sign for 0% when there is no change

When all samples are identical, instead of printing
+0.00%, print just 0.00%.

This is not just more accurate.
When benchmarking the compiler, one item of interest
is the impact on object file and executable sizes.
These can change by tiny amounts, below two sig figs.
However, the existence of any change is sometimes a cue
to the reader to investigate further.
This obviously should not be relied on,
but it is nevertheless a useful signal.

Change-Id: I1e5157a52fc47c6871ca87b0e9cff223f4fd43d9
Reviewed-on: https://go-review.googlesource.com/44190
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 0da03b58
......@@ -99,12 +99,16 @@ func (c *Collection) Tables() []*Table {
} else if testerr != nil {
row.Note = fmt.Sprintf("(%s)", testerr)
} else if pval < alpha {
pct := ((new.Mean / old.Mean) - 1.0) * 100.0
row.Delta = fmt.Sprintf("%+.2f%%", pct)
if pct < 0 == (table.Metric != "speed") { // smaller is better, except speeds
row.Change = +1
if new.Mean == old.Mean {
row.Delta = "0.00%"
} else {
row.Change = -1
pct := ((new.Mean / old.Mean) - 1.0) * 100.0
row.Delta = fmt.Sprintf("%+.2f%%", pct)
if pct < 0 == (table.Metric != "speed") { // smaller is better, except speeds
row.Change = +1
} else {
row.Change = -1
}
}
}
if row.Note == "" && pval != -1 {
......
......@@ -39,6 +39,7 @@ func TestGolden(t *testing.T) {
check(t, "packagesold", "packagesold.txt")
check(t, "packages", "packagesold.txt", "packagesnew.txt")
check(t, "units", "units-old.txt", "units-new.txt")
check(t, "zero", "-delta-test=none", "zero-old.txt", "zero-new.txt")
}
func check(t *testing.T, name string, files ...string) {
......
pkg: synthetic
note: test benchstat printing of zeros
BenchmarkImperceptible 1 1234567890 a-bytes 171717171716 b-bytes 99999930 c-bytes
pkg: synthetic
note: test benchstat printing of zeros
BenchmarkImperceptible 1 1234567890 a-bytes 171717171717 b-bytes 99999929 c-bytes
name old a-bytes new a-bytes delta
Imperceptible 1.23GB ± 0% 1.23GB ± 0% 0.00%
name old b-bytes new b-bytes delta
Imperceptible 172GB ± 0% 172GB ± 0% -0.00%
name old c-bytes new c-bytes delta
Imperceptible 100MB ± 0% 100MB ± 0% +0.00%
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