1
0

Add BenchmarkRWMutexInterfaceMapGetString

This commit is contained in:
Patrick Mylund Nielsen 2015-12-03 09:55:58 -05:00
parent 8c41258ef3
commit 721cc9438c

View File

@ -1457,7 +1457,7 @@ func BenchmarkRWMutexMapGet(b *testing.B) {
} }
} }
func BenchmarkRWMutexInterfaceMapGet(b *testing.B) { func BenchmarkRWMutexInterfaceMapGetStruct(b *testing.B) {
b.StopTimer() b.StopTimer()
s := struct{name string}{name: "foo"} s := struct{name string}{name: "foo"}
m := map[interface{}]string{ m := map[interface{}]string{
@ -1472,6 +1472,20 @@ func BenchmarkRWMutexInterfaceMapGet(b *testing.B) {
} }
} }
func BenchmarkRWMutexInterfaceMapGetString(b *testing.B) {
b.StopTimer()
m := map[interface{}]string{
"foo": "bar",
}
mu := sync.RWMutex{}
b.StartTimer()
for i := 0; i < b.N; i++ {
mu.RLock()
_, _ = m["foo"]
mu.RUnlock()
}
}
func BenchmarkCacheGetConcurrentExpiring(b *testing.B) { func BenchmarkCacheGetConcurrentExpiring(b *testing.B) {
benchmarkCacheGetConcurrent(b, 5*time.Minute) benchmarkCacheGetConcurrent(b, 5*time.Minute)
} }