func BAtomicWaitUpdate(b *testing.B, sm api.StoredMap) { var k string l := len(UniqKey) b.ReportAllocs() b.SetBytes(2) b.ResetTimer() for i := 0; i < b.N; i++ { k = UniqKey[i%l] sm.AtomicWait(func(m api.Mapper) { m.SetKey(k) m.Update(k) }) } }
func BAtomicWaitFind(b *testing.B, sm api.StoredMap) { var k string l := len(UniqKey) b.ReportAllocs() b.SetBytes(2) b.ResetTimer() for i := 0; i < b.N; i++ { k = UniqKey[i%l] sm.AtomicWait(func(m api.Mapper) { if value, found := m.Find(k); found { _ = value.(string) } }) } }
func BThreadsAtomicWaitUpdate(b *testing.B, sm api.StoredMap) { l := len(UniqKey) b.SetParallelism(CntBenchWorks) b.ReportAllocs() b.SetBytes(2) b.ResetTimer() b.RunParallel(func(pb *testing.PB) { var k string var i int for pb.Next() { k = UniqKey[i%l] sm.AtomicWait(func(m api.Mapper) { m.SetKey(k) m.Update(k) }) i++ } }) }
func BThreadsAtomicWaitFind(b *testing.B, sm api.StoredMap) { l := len(UniqKey) b.SetParallelism(CntBenchWorks) b.ReportAllocs() b.SetBytes(2) b.ResetTimer() b.RunParallel(func(pb *testing.PB) { var k string var i int for pb.Next() { k = UniqKey[i%l] sm.AtomicWait(func(m api.Mapper) { if value, found := m.Find(k); found { _ = value.(string) } }) i++ } }) }