mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Use a static array in benchmarks.
Since d2858aeb7e
the caller is permitted
to reuse its slice again.
This commit is contained in:
parent
590d158df8
commit
6bae31f077
1 changed files with 4 additions and 10 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue