MCPcopy
hub / github.com/cornelk/hashmap / BenchmarkReadGoMapWithWritesUintMutex

Function BenchmarkReadGoMapWithWritesUintMutex

benchmarks/benchmark_test.go:218–247  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

216}
217
218func 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
249func BenchmarkReadGoSyncMapUint(b *testing.B) {
250 m := setupGoSyncMap(b)

Callers

nothing calls this directly

Calls 2

setupGoMapFunction · 0.85
NextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…