From ac4bda9deaef83e9d9e78d0ee9c4c85ea46994fd Mon Sep 17 00:00:00 2001 From: Patrick Mylund Nielsen Date: Wed, 4 Jan 2012 10:06:31 +0100 Subject: [PATCH] BenchmarkCacheSetDeleteSingleLock to get an idea of mutex impact --- cache_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cache_test.go b/cache_test.go index df52767..d7bda82 100644 --- a/cache_test.go +++ b/cache_test.go @@ -409,7 +409,7 @@ func TestFlush(t *testing.T) { } } -func BenchmarkCache(b *testing.B) { +func BenchmarkCacheGet(b *testing.B) { tc := New(0, 0) tc.Set("foo", "bar", 0) for i := 0; i < b.N; i++ { @@ -417,7 +417,7 @@ func BenchmarkCache(b *testing.B) { } } -func BenchmarkMap(b *testing.B) { +func BenchmarkMapGet(b *testing.B) { m := map[string]string{ "foo": "bar", } @@ -448,6 +448,16 @@ func BenchmarkCacheSetDelete(b *testing.B) { } } +func BenchmarkCacheSetDeleteSingleLock(b *testing.B) { + tc := New(0, 0) + tc.mu.Lock() + defer tc.mu.Unlock() + for i := 0; i < b.N; i++ { + tc.set("foo", "bar", 0) + tc.delete("foo") + } +} + func BenchmarkMapSetDelete(b *testing.B) { m := map[string]string{} for i := 0; i < b.N; i++ {