]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: add benchmark for UAPI Device.IpcGetOperation
authorJosh Bleecher Snyder <josh@tailscale.com>
Tue, 26 Jan 2021 19:39:48 +0000 (11:39 -0800)
committerBrad Fitzpatrick <bradfitz@tailscale.com>
Tue, 26 Jan 2021 19:40:24 +0000 (11:40 -0800)
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
device/device_test.go

index 62dee5680f7550502b823d97d9e63e39d98caf04..caae2b839fb8aa073f0aa641347ff98b9dcdfb98 100644 (file)
@@ -10,6 +10,7 @@ import (
        "errors"
        "fmt"
        "io"
+       "io/ioutil"
        "net"
        "sync"
        "sync/atomic"
@@ -340,3 +341,14 @@ func BenchmarkThroughput(b *testing.B) {
        b.ReportMetric(float64(elapsed)/float64(b.N), "ns/op")
        b.ReportMetric(1-float64(b.N)/float64(sent), "packet-loss")
 }
+
+func BenchmarkUAPIGet(b *testing.B) {
+       pair := genTestPair(b)
+       pair.Send(b, Ping, nil)
+       pair.Send(b, Pong, nil)
+       b.ReportAllocs()
+       b.ResetTimer()
+       for i := 0; i < b.N; i++ {
+               pair[0].dev.IpcGetOperation(ioutil.Discard)
+       }
+}