mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-15 19:03:27 +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
@@ -1194,6 +1194,10 @@ func addTestEndpoint(tb testing.TB, conn *Conn, sendConn net.PacketConn) (tailcf
|
||||
}
|
||||
|
||||
func setUpReceiveFrom(tb testing.TB) (roundTrip func()) {
|
||||
if b, ok := tb.(*testing.B); ok {
|
||||
b.ReportAllocs()
|
||||
}
|
||||
|
||||
conn := newTestConn(tb)
|
||||
tb.Cleanup(func() { conn.Close() })
|
||||
conn.logf = logger.Discard
|
||||
@@ -1295,6 +1299,7 @@ func BenchmarkReceiveFrom(b *testing.B) {
|
||||
}
|
||||
|
||||
func BenchmarkReceiveFrom_Native(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
recvConn, err := net.ListenPacket("udp4", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
|
Reference in New Issue
Block a user