bigcache-bench
bigcache-bench copied to clipboard
Make GC comparisons more realistic
This change generates the keys and values in advance. This means the measurements of the GC impact of the cache algorithms is no longer tainted by key/value creation, which comes with a lot of heap allocations.
After
$ go run caches_gc_overhead_comparison.go -cache stdmap
Cache: stdmap
Number of entries: 20000000
Number of repeats: 50
Value size: 100
GC pause for startup: 232.824µs
GC pause for stdmap: 5.49024ms
$ go run caches_gc_overhead_comparison.go -cache freecache
Cache: freecache
Number of entries: 20000000
Number of repeats: 50
Value size: 100
GC pause for startup: 1.112992ms
GC pause for freecache: 26.927167ms
$ go run caches_gc_overhead_comparison.go -cache bigcache
Cache: bigcache
Number of entries: 20000000
Number of repeats: 50
Value size: 100
GC pause for startup: 424.326µs
GC pause for bigcache: 29.979629ms