From e58a7a95f45ca8db8d4be87b4edcda05abcc8867 Mon Sep 17 00:00:00 2001 From: Giuseppe Date: Tue, 1 Dec 2015 22:08:24 +0100 Subject: [PATCH] changed test --- cache_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cache_test.go b/cache_test.go index 3406997..d02ad84 100644 --- a/cache_test.go +++ b/cache_test.go @@ -1648,6 +1648,17 @@ func BenchmarkDeleteExpiredLoop(b *testing.B) { } } +func BenchmarkLargeCache(b *testing.B) { + b.StopTimer() + tc := New(100*time.Millisecond, 1*time.Millisecond) + b.StartTimer() + b.N = 1000000 + for i := 0; i < b.N; i++ { + tc.Set(strconv.Itoa(i), "bar", DefaultExpiration) + } +} + +/* func BenchmarkLargeCache(b *testing.B) { b.StopTimer() tc := New(time.Second, 10*time.Millisecond) @@ -1657,11 +1668,11 @@ func BenchmarkLargeCache(b *testing.B) { tc.Set(strconv.Itoa(i), "bar", DefaultExpiration) i++ } - /* + for i := 0; i < 1000000; i++ { tc.Set(strconv.Itoa(i), "bar", DefaultExpiration) } - */ + tc.DeleteExpired() b.Logf("Cache size: %d", tc.ItemCount()) b.StartTimer() @@ -1669,3 +1680,4 @@ func BenchmarkLargeCache(b *testing.B) { tc.Set(strconv.Itoa(i), "bar", DefaultExpiration) } } +*/