Make BenchmarkDeleteExpired more meaningful
This commit is contained in:
parent
cf4e165754
commit
28ab885a1a
|
@ -1604,16 +1604,14 @@ func BenchmarkIncrementInt(b *testing.B) {
|
||||||
|
|
||||||
func BenchmarkDeleteExpired(b *testing.B) {
|
func BenchmarkDeleteExpired(b *testing.B) {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
tc := New(1, 0)
|
tc := New(5 * time.Minute, 0)
|
||||||
tc.mu.Lock()
|
tc.mu.Lock()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < 100000; i++ {
|
||||||
tc.set(strconv.Itoa(i), "bar", DefaultExpiration)
|
tc.set(strconv.Itoa(i), "bar", DefaultExpiration)
|
||||||
}
|
}
|
||||||
tc.mu.Unlock()
|
tc.mu.Unlock()
|
||||||
time.Sleep(100)
|
|
||||||
if _, found := tc.Get("0"); found {
|
|
||||||
b.Fatal("0 found")
|
|
||||||
}
|
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
tc.DeleteExpired()
|
for i := 0; i < b.N; i++ {
|
||||||
|
tc.DeleteExpired()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue