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 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 }) }