github.com/evdatsion/aphelion-dpos-bft@v0.32.1/benchmarks/atomic_test.go (about) 1 package benchmarks 2 3 import ( 4 "sync/atomic" 5 "testing" 6 "unsafe" 7 ) 8 9 func BenchmarkAtomicUintPtr(b *testing.B) { 10 b.StopTimer() 11 pointers := make([]uintptr, 1000) 12 b.Log(unsafe.Sizeof(pointers[0])) 13 b.StartTimer() 14 15 for j := 0; j < b.N; j++ { 16 atomic.StoreUintptr(&pointers[j%1000], uintptr(j)) 17 } 18 } 19 20 func BenchmarkAtomicPointer(b *testing.B) { 21 b.StopTimer() 22 pointers := make([]unsafe.Pointer, 1000) 23 b.Log(unsafe.Sizeof(pointers[0])) 24 b.StartTimer() 25 26 for j := 0; j < b.N; j++ { 27 atomic.StorePointer(&pointers[j%1000], unsafe.Pointer(uintptr(j))) 28 } 29 }