mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
all: add (*testing.B).ReportAllocs() to every benchmark
This ensures that we can properly track and catch allocation slippages that could otherwise have been missed. Fixes #2748
This commit is contained in:

committed by
Brad Fitzpatrick

parent
44d71d1e42
commit
0daa32943e
@@ -35,12 +35,14 @@ func TestUnmarshalZero(t *testing.T) {
|
||||
}
|
||||
|
||||
func BenchmarkMonoNow(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
Now()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkTimeNow(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
time.Now()
|
||||
}
|
||||
|
@@ -152,7 +152,6 @@ func BenchmarkParse3339(b *testing.B) {
|
||||
run := func(in string) func(*testing.B) {
|
||||
return func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
t, err := time.Parse(time.RFC3339Nano, in)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
@@ -182,6 +181,7 @@ func BenchmarkParse3339(b *testing.B) {
|
||||
}
|
||||
|
||||
func BenchmarkParseInt(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
var out int
|
||||
for i := 0; i < b.N; i++ {
|
||||
parseInt(mem.S("148487491"), &out)
|
||||
|
Reference in New Issue
Block a user