func BThreadsAtomicComplex(b *testing.B, sm api.StoredMap) { l := len(UniqKey) inserter := func(key string) { sm.Atomic(func(m api.Mapper) { if value, found := m.Find(key); found { _ = value.(string) return } m.SetKey(key) m.Update(key) }) } 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] inserter(k) i++ } }) }
func BEachFullCicle(b *testing.B, sm api.StoredMap) { b.ReportAllocs() b.SetBytes(2) b.ResetTimer() for i := 0; i < b.N; i++ { sm.Each(func(m api.Mapper) { _ = m.Value().(string) }) } }
func BInsert(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.Insert(k, k) } }
func BFind(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] if value, found := sm.Find(k); found { _ = value.(string) } } }
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 BThreadsDelete(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.Delete(k) i++ } }) }
func BThreadsEachShort(b *testing.B, sm api.StoredMap) { b.SetParallelism(CntBenchWorks) b.ReportAllocs() b.SetBytes(2) b.ResetTimer() b.RunParallel(func(pb *testing.PB) { var i int for pb.Next() { sm.Each(func(m api.Mapper) { _ = m.Value().(string) m.Stop() }) i++ } }) }
func BAtomicUpdate(b *testing.B, sm api.StoredMap) { var k string l := len(UniqKey) inserter := func(key string) { sm.Atomic(func(m api.Mapper) { m.SetKey(key) m.Update(key) }) } b.ReportAllocs() b.SetBytes(2) b.ResetTimer() for i := 0; i < b.N; i++ { k = UniqKey[i%l] inserter(k) } }
func BThreadsFind(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] if value, found := sm.Find(k); found { _ = value.(string) } i++ } }) }
func BUpdate(b *testing.B, sm api.StoredMap) { var k string l := len(UniqKey) updater := func(key string) { sm.Update(key, func(value interface{}, found bool) interface{} { if found { _ = value.(string) } return key }) } b.ReportAllocs() b.SetBytes(2) b.ResetTimer() for i := 0; i < b.N; i++ { k = UniqKey[i%l] updater(k) } }
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 BAtomicComplex(b *testing.B, sm api.StoredMap) { var k string l := len(UniqKey) inserter := func(key string) { sm.Atomic(func(m api.Mapper) { if value, found := m.Find(key); found { _ = value.(string) return } m.SetKey(key) m.Update(key) }) } b.ReportAllocs() b.SetBytes(2) b.ResetTimer() for i := 0; i < b.N; i++ { k = UniqKey[i%l] inserter(k) } }
func BThreadsUpdate(b *testing.B, sm api.StoredMap) { l := len(UniqKey) updater := func(key string) { sm.Update(key, func(value interface{}, found bool) interface{} { if found { _ = value.(string) } return key }) } 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] updater(k) i++ } }) }
func testUpdate(sm api.StoredMap, t *test.Item, f func(string, bool)) { sm.Update(t.K, func(value interface{}, found bool) interface{} { f(t.K, found) return t.V }) }
func update(sm api.StoredMap, t *test.Item) { sm.Update(t.K, func(value interface{}, found bool) interface{} { t.Done <- t return t.V }) }