Add a benchmark for DeleteExpired()
This commit is contained in:
parent
0ba3e0049c
commit
3d4d09ca0b
@ -1591,3 +1591,19 @@ func BenchmarkRWMutexMapSetDeleteSingleLock(b *testing.B) {
|
|||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkDeleteExpired(b *testing.B) {
|
||||||
|
b.StopTimer()
|
||||||
|
tc := New(1, 0)
|
||||||
|
tc.mu.Lock()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
tc.set(strconv.Itoa(i), "bar", DefaultExpiration)
|
||||||
|
}
|
||||||
|
tc.mu.Unlock()
|
||||||
|
time.Sleep(100)
|
||||||
|
if _, found := tc.Get("0"); found {
|
||||||
|
b.Fatal("0 found")
|
||||||
|
}
|
||||||
|
b.StartTimer()
|
||||||
|
tc.DeleteExpired()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user