aboutsummaryrefslogtreecommitdiffstats
path: root/device/device_test.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-02-03 16:54:45 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-03 16:59:29 +0100
commitc3bde5f59099a3b21b016bf809b83ee3de126f80 (patch)
tree35167c928fd71b19d6524beb24c395a4bcefb9c2 /device/device_test.go
parentdevice: test that we do not leak goroutines (diff)
downloadwireguard-go-c3bde5f59099a3b21b016bf809b83ee3de126f80.tar.xz
wireguard-go-c3bde5f59099a3b21b016bf809b83ee3de126f80.zip
device: benchmark the waitpool to compare it to the prior channels
Here is the old implementation: type WaitPool struct { c chan interface{} } func NewWaitPool(max uint32, new func() interface{}) *WaitPool { p := &WaitPool{c: make(chan interface{}, max)} for i := uint32(0); i < max; i++ { p.c <- new() } return p } func (p *WaitPool) Get() interface{} { return <- p.c } func (p *WaitPool) Put(x interface{}) { p.c <- x } It performs worse than the new one: name old time/op new time/op delta WaitPool-16 16.4µs ± 5% 15.1µs ± 3% -7.86% (p=0.008 n=5+5) Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/device_test.go')
0 files changed, 0 insertions, 0 deletions