Example #1
0
func BenchmarkBuiltinUnsafeMap(b *testing.B) {
	m := make(map[string]interface{})
	for i := 0; i < ('~'-'!')*('~'-'!'); i++ {
		m[rand.RandomString(2)] = 1
	}
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		key := rand.RandomString(2)
		m[key] = 1
		_, _ = m[key]
	}
}
Example #2
0
func BenchmarkSetAndGetWithShard32(b *testing.B) {
	cm := New()
	for i := 0; i < ('~'-'!')*('~'-'!'); i++ {
		cm.Set(rand.RandomString(2), 1)
	}
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		key := rand.RandomString(2)
		cm.Set(key, 1)
		_, _ = cm.Get(key)
	}
}