Example #1
0
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)
		})
	}
}
Example #2
0
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)
			}
		})
	}
}
Example #3
0
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++
		}
	})
}
Example #4
0
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++
		}
	})
}