aboutsummaryrefslogtreecommitdiff
path: root/device/device_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2022-08-30 07:43:11 -0700
committerBrad Fitzpatrick <bradfitz@tailscale.com>2022-08-30 09:24:09 -0700
commit020d65481bdc616d4654d33c9e833f0ed9fbe351 (patch)
tree60a726df8938313fb4e20309c0e8735be5979299 /device/device_test.go
parentd1d08426b27b57990b1ee6782794f56d2c002aa3 (diff)
downloadwireguard-go-bf/atomic/for-jason.tar.gz
wireguard-go-bf/atomic/for-jason.zip
all: use Go 1.19 and its atomic typesbf/atomic/for-jason
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.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
}