Skip to content

Commit 721cc94

Browse files
committed
Add BenchmarkRWMutexInterfaceMapGetString
1 parent 8c41258 commit 721cc94

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

cache_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ func BenchmarkRWMutexMapGet(b *testing.B) {
14571457
}
14581458
}
14591459

1460-
func BenchmarkRWMutexInterfaceMapGet(b *testing.B) {
1460+
func BenchmarkRWMutexInterfaceMapGetStruct(b *testing.B) {
14611461
b.StopTimer()
14621462
s := struct{name string}{name: "foo"}
14631463
m := map[interface{}]string{
@@ -1472,6 +1472,20 @@ func BenchmarkRWMutexInterfaceMapGet(b *testing.B) {
14721472
}
14731473
}
14741474

1475+
func BenchmarkRWMutexInterfaceMapGetString(b *testing.B) {
1476+
b.StopTimer()
1477+
m := map[interface{}]string{
1478+
"foo": "bar",
1479+
}
1480+
mu := sync.RWMutex{}
1481+
b.StartTimer()
1482+
for i := 0; i < b.N; i++ {
1483+
mu.RLock()
1484+
_, _ = m["foo"]
1485+
mu.RUnlock()
1486+
}
1487+
}
1488+
14751489
func BenchmarkCacheGetConcurrentExpiring(b *testing.B) {
14761490
benchmarkCacheGetConcurrent(b, 5*time.Minute)
14771491
}

0 commit comments

Comments
 (0)