コード例 #1
0
ファイル: map_test.go プロジェクト: dgraph-io/experiments
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)
			}
		}
	})
}
コード例 #2
0
ファイル: map_test.go プロジェクト: dgraph-io/experiments
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))
			}
		}
	})
}