From 28ab885a1a99d5b142901e78c44d1b85f9d01ef0 Mon Sep 17 00:00:00 2001 From: Patrick Mylund Nielsen Date: Sat, 28 Nov 2015 15:13:26 -0500 Subject: [PATCH] Make BenchmarkDeleteExpired more meaningful --- cache_test.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cache_test.go b/cache_test.go index 86a5283..f998d43 100644 --- a/cache_test.go +++ b/cache_test.go @@ -1604,16 +1604,14 @@ func BenchmarkIncrementInt(b *testing.B) { func BenchmarkDeleteExpired(b *testing.B) { b.StopTimer() - tc := New(1, 0) + tc := New(5 * time.Minute, 0) tc.mu.Lock() - for i := 0; i < b.N; i++ { + for i := 0; i < 100000; 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() + for i := 0; i < b.N; i++ { + tc.DeleteExpired() + } }