Skip to content

Commit 28ab885

Browse files
committed
Make BenchmarkDeleteExpired more meaningful
1 parent cf4e165 commit 28ab885

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

cache_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,16 +1604,14 @@ func BenchmarkIncrementInt(b *testing.B) {
16041604

16051605
func BenchmarkDeleteExpired(b *testing.B) {
16061606
b.StopTimer()
1607-
tc := New(1, 0)
1607+
tc := New(5 * time.Minute, 0)
16081608
tc.mu.Lock()
1609-
for i := 0; i < b.N; i++ {
1609+
for i := 0; i < 100000; i++ {
16101610
tc.set(strconv.Itoa(i), "bar", DefaultExpiration)
16111611
}
16121612
tc.mu.Unlock()
1613-
time.Sleep(100)
1614-
if _, found := tc.Get("0"); found {
1615-
b.Fatal("0 found")
1616-
}
16171613
b.StartTimer()
1618-
tc.DeleteExpired()
1614+
for i := 0; i < b.N; i++ {
1615+
tc.DeleteExpired()
1616+
}
16191617
}

0 commit comments

Comments
 (0)