Skip to content

Commit 8c41258

Browse files
committed
Add BenchmarkRWMutexInterfaceMapGet
1 parent faf8383 commit 8c41258

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cache_test.go

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

1460+
func BenchmarkRWMutexInterfaceMapGet(b *testing.B) {
1461+
b.StopTimer()
1462+
s := struct{name string}{name: "foo"}
1463+
m := map[interface{}]string{
1464+
s: "bar",
1465+
}
1466+
mu := sync.RWMutex{}
1467+
b.StartTimer()
1468+
for i := 0; i < b.N; i++ {
1469+
mu.RLock()
1470+
_, _ = m[s]
1471+
mu.RUnlock()
1472+
}
1473+
}
1474+
14601475
func BenchmarkCacheGetConcurrentExpiring(b *testing.B) {
14611476
benchmarkCacheGetConcurrent(b, 5*time.Minute)
14621477
}

0 commit comments

Comments
 (0)