diff options
author | David Fifield <david@bamsoftware.com> | 2023-04-04 16:56:46 -0600 |
---|---|---|
committer | David Fifield <david@bamsoftware.com> | 2023-04-04 18:56:55 -0600 |
commit | 6bae31f07782776fb4c289dec6f7e10233609eef (patch) | |
tree | 477680949f50ac6a287ed10cd3325e03b1ab373a | |
parent | 590d158df82e0f702fddea35d0e58cc914596f35 (diff) | |
download | snowflake-6bae31f07782776fb4c289dec6f7e10233609eef.tar.gz snowflake-6bae31f07782776fb4c289dec6f7e10233609eef.zip |
Use a static array in benchmarks.
Since d2858aeb7ec50ae09b9a7e2e2a910ae31cec62bd the caller is permitted
to reuse its slice again.
-rw-r--r-- | common/turbotunnel/queuepacketconn_test.go | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/common/turbotunnel/queuepacketconn_test.go b/common/turbotunnel/queuepacketconn_test.go index e7eb90f..2bb4eeb 100644 --- a/common/turbotunnel/queuepacketconn_test.go +++ b/common/turbotunnel/queuepacketconn_test.go @@ -27,12 +27,9 @@ func BenchmarkQueueIncoming(b *testing.B) { defer conn.Close() b.ResetTimer() - s := 500 + var p [500]byte for i := 0; i < b.N; i++ { - // Use a variable for the length to stop the compiler from - // optimizing out the allocation. - p := make([]byte, s) - conn.QueueIncoming(p, emptyAddr{}) + conn.QueueIncoming(p[:], emptyAddr{}) } b.StopTimer() } @@ -43,12 +40,9 @@ func BenchmarkWriteTo(b *testing.B) { defer conn.Close() b.ResetTimer() - s := 500 + var p [500]byte for i := 0; i < b.N; i++ { - // Use a variable for the length to stop the compiler from - // optimizing out the allocation. - p := make([]byte, s) - conn.WriteTo(p, emptyAddr{}) + conn.WriteTo(p[:], emptyAddr{}) } b.StopTimer() } |