Package list golang-github-renekroon-ttlcache / 018f250
Update upstream source from tag 'upstream/1.6.0+ds' Update to upstream version '1.6.0+ds' with Debian dir 19dcb0e53f1fa831f89c2972050ff5fe18607c59 Sascha Steinbiss 1 year, 10 months ago
1 changed file(s) with 0 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
+0
-36
bench/bench_test.go less more
0 package bench
1
2 import (
3 "testing"
4 "time"
5
6 "github.com/ReneKroon/ttlcache"
7 )
8
9 func BenchmarkCacheSetWithoutTTL(b *testing.B) {
10 cache := ttlcache.NewCache()
11 defer cache.Close()
12
13 for n := 0; n < b.N; n++ {
14 cache.Set(string(n%1000000), "value")
15 }
16 }
17
18 func BenchmarkCacheSetWithGlobalTTL(b *testing.B) {
19 cache := ttlcache.NewCache()
20 defer cache.Close()
21
22 cache.SetTTL(time.Duration(50 * time.Millisecond))
23 for n := 0; n < b.N; n++ {
24 cache.Set(string(n%1000000), "value")
25 }
26 }
27
28 func BenchmarkCacheSetWithTTL(b *testing.B) {
29 cache := ttlcache.NewCache()
30 defer cache.Close()
31
32 for n := 0; n < b.N; n++ {
33 cache.SetWithTTL(string(n%1000000), "value", time.Duration(50*time.Millisecond))
34 }
35 }