(b *testing.B)
| 216 | } |
| 217 | |
| 218 | func BenchmarkReadGoMapWithWritesUintMutex(b *testing.B) { |
| 219 | m := setupGoMap(b) |
| 220 | l := &sync.RWMutex{} |
| 221 | var writer uintptr |
| 222 | b.ResetTimer() |
| 223 | |
| 224 | b.RunParallel(func(pb *testing.PB) { |
| 225 | // use 1 thread as writer |
| 226 | if atomic.CompareAndSwapUintptr(&writer, 0, 1) { |
| 227 | for pb.Next() { |
| 228 | for i := uintptr(0); i < benchmarkItemCount; i++ { |
| 229 | l.Lock() |
| 230 | m[i] = i |
| 231 | l.Unlock() |
| 232 | } |
| 233 | } |
| 234 | } else { |
| 235 | for pb.Next() { |
| 236 | for i := uintptr(0); i < benchmarkItemCount; i++ { |
| 237 | l.RLock() |
| 238 | j := m[i] |
| 239 | l.RUnlock() |
| 240 | if j != i { |
| 241 | b.Fail() |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | }) |
| 247 | } |
| 248 | |
| 249 | func BenchmarkReadGoSyncMapUint(b *testing.B) { |
| 250 | m := setupGoSyncMap(b) |
nothing calls this directly
no test coverage detected
searching dependent graphs…