Skip to content
Snippets Groups Projects
Commit a7e18c55 authored by David Fifield's avatar David Fifield
Browse files

Benchmark for QueuePacketConn.QueueIncoming.

	$ go test -bench=BenchmarkQueueIncoming -benchtime=2s -benchmem
	BenchmarkQueueIncoming-4         7001494               342.4 ns/op          1024 B/op          2 allocs/op
parent da350e4a
No related branches found
No related tags found
No related merge requests found
package turbotunnel
import (
"testing"
"time"
)
type emptyAddr struct{}
func (_ emptyAddr) Network() string { return "empty" }
func (_ emptyAddr) String() string { return "empty" }
// Run with -benchmem to see memory allocations.
func BenchmarkQueueIncoming(b *testing.B) {
conn := NewQueuePacketConn(emptyAddr{}, 1*time.Hour)
defer conn.Close()
b.ResetTimer()
s := 500
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{})
}
b.StopTimer()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment