github.com/mattn/go@v0.0.0-20171011075504-07f7db3ea99f/src/runtime/internal/atomic/bench_test.go (about)

     1  // Copyright 2016 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package atomic_test
     6  
     7  import (
     8  	"runtime/internal/atomic"
     9  	"testing"
    10  )
    11  
    12  var sink interface{}
    13  
    14  func BenchmarkAtomicLoad64(b *testing.B) {
    15  	var x uint64
    16  	sink = &x
    17  	for i := 0; i < b.N; i++ {
    18  		_ = atomic.Load64(&x)
    19  	}
    20  }
    21  
    22  func BenchmarkAtomicStore64(b *testing.B) {
    23  	var x uint64
    24  	sink = &x
    25  	for i := 0; i < b.N; i++ {
    26  		atomic.Store64(&x, 0)
    27  	}
    28  }