sm
/
cache
1
0
Fork 0

BenchmarkCacheSetDeleteSingleLock to get an idea of mutex impact

This commit is contained in:
Patrick Mylund Nielsen 2012-01-04 10:06:31 +01:00
parent e46251e025
commit ac4bda9dea
1 changed files with 12 additions and 2 deletions

View File

@ -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++ {