Ejemplo n.º 1
0
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)
		}
	}
}
Ejemplo n.º 2
0
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++
		}
	})
}