mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-20 16:45:56 +08:00
20 lines
293 B
Go
20 lines
293 B
Go
package main
|
|
|
|
import (
|
|
"sync/atomic"
|
|
"testing"
|
|
)
|
|
|
|
func BenchmarkAtomicStoreInt32(b *testing.B) {
|
|
var v int32
|
|
for i := 0; i < b.N; i++ {
|
|
atomic.StoreInt32(&v, 1)
|
|
}
|
|
}
|
|
|
|
func BenchmarkAtomicStoreInt64(b *testing.B) {
|
|
var v int64
|
|
for i := 0; i < b.N; i++ {
|
|
atomic.StoreInt64(&v, 1)
|
|
}
|
|
}
|