Esempio n. 1
0
func BenchmarkGotomic(b *testing.B) {
	h := gotomic.NewHash()
	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			key := uint64(rand.Int63())
			_, has := h.Get(gotomic.IntKey(key))
			if !has {
				l := posting.NewList()
				h.Put(gotomic.IntKey(key), l)
			}
		}
	})
}
Esempio n. 2
0
func BenchmarkGetAndPut(b *testing.B) {
	m := NewMap(1 << 16)
	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			key := uint64(rand.Int63())
			p := m.Get(key)
			if p == nil {
				l := posting.NewList()
				m.Put(key, unsafe.Pointer(l))
			}
		}
	})
}