Addressing code review comments.

Mainly:
* Moving the averaging/merging of benchmarks from the parser to the formatter package
* Tightening up the regex so it only captures the numeric values (no more of trimming spaces and the ns/op)
* Deleting the writing up in xml file the benchmark memory sections of B/op and Allocs/op

Also added a test case for parseNanoseconds().
This commit is contained in:
Brittany Walentin
2018-05-25 10:59:00 -07:00
parent b2f467b67c
commit 260b47cabe
9 changed files with 185 additions and 128 deletions

View File

@ -24,3 +24,24 @@ func TestParseSeconds(t *testing.T) {
}
}
}
func TestParseNanoseconds(t *testing.T) {
tests := []struct {
in string
d time.Duration
}{
{"", 0},
{"0.1", 0 * time.Nanosecond},
{"0.9", 0 * time.Nanosecond},
{"4", 4 * time.Nanosecond},
{"5000", 5 * time.Microsecond},
{"2000003", 2*time.Millisecond + 3*time.Nanosecond},
}
for _, test := range tests {
d := parseNanoseconds(test.in)
if d != test.d {
t.Errorf("parseSeconds(%q) == %v, want %v\n", test.in, d, test.d)
}
}
}