aboutsummaryrefslogtreecommitdiff
path: root/device/device_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2022-08-30 07:43:11 -0700
committerJason A. Donenfeld <Jason@zx2c4.com>2022-09-04 12:57:30 +0200
commitb51010ba13f0a3e59808fbdb1566cd2c6b834b95 (patch)
tree37a6753e5604c13f7141bd5613b0ab80e7b794f7 /device/device_test.go
parentd1d08426b27b57990b1ee6782794f56d2c002aa3 (diff)
downloadwireguard-go-b51010ba13f0a3e59808fbdb1566cd2c6b834b95.tar.gz
wireguard-go-b51010ba13f0a3e59808fbdb1566cd2c6b834b95.zip
all: use Go 1.19 and its atomic types
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/device_test.go')
-rw-r--r--device/device_test.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/device/device_test.go b/device/device_test.go
index ab7236e..8cffe08 100644
--- a/device/device_test.go
+++ b/device/device_test.go
@@ -333,7 +333,7 @@ func BenchmarkThroughput(b *testing.B) {
// Measure how long it takes to receive b.N packets,
// starting when we receive the first packet.
- var recv uint64
+ var recv atomic.Uint64
var elapsed time.Duration
var wg sync.WaitGroup
wg.Add(1)
@@ -342,7 +342,7 @@ func BenchmarkThroughput(b *testing.B) {
var start time.Time
for {
<-pair[0].tun.Inbound
- new := atomic.AddUint64(&recv, 1)
+ new := recv.Add(1)
if new == 1 {
start = time.Now()
}
@@ -358,7 +358,7 @@ func BenchmarkThroughput(b *testing.B) {
ping := tuntest.Ping(pair[0].ip, pair[1].ip)
pingc := pair[1].tun.Outbound
var sent uint64
- for atomic.LoadUint64(&recv) != uint64(b.N) {
+ for recv.Load() != uint64(b.N) {
sent++
pingc <- ping
}