Fix BenchmarkCacheSetDeleteSingleLock 'cheating' by unintentionally only locking once in the whole benchmark, rather than once per set and delete

This commit is contained in:
Patrick Mylund Nielsen 2012-06-22 06:52:32 +01:00
parent 0a962bf9eb
commit 0f0584a805
1 changed files with 2 additions and 2 deletions

View File

@ -735,12 +735,12 @@ func BenchmarkMutexMapSetDelete(b *testing.B) {
func BenchmarkCacheSetDeleteSingleLock(b *testing.B) { func BenchmarkCacheSetDeleteSingleLock(b *testing.B) {
tc := New(0, 0) tc := New(0, 0)
tc.mu.Lock()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
tc.mu.Lock()
tc.set("foo", "bar", 0) tc.set("foo", "bar", 0)
tc.delete("foo") tc.delete("foo")
tc.mu.Unlock()
} }
tc.mu.Unlock()
} }
func BenchmarkMutexMapSetDeleteSingleLock(b *testing.B) { func BenchmarkMutexMapSetDeleteSingleLock(b *testing.B) {