kevburnsjr / microcache

A non-standard HTTP cache implemented as Go middleware
MIT License
155 stars 5 forks source link

Add benchmark tests #13

Closed kevburnsjr closed 5 years ago

kevburnsjr commented 5 years ago
$ go test -bench=. -benchmem
goos: linux
goarch: amd64
pkg: github.com/kevburnsjr/microcache
BenchmarkHits-12                            827476   1449 ns/op    678 B/op   14 allocs/op
BenchmarkNocache-12                        1968576    613 ns/op    312 B/op    6 allocs/op
BenchmarkMisses-12                          307652   3890 ns/op   1765 B/op   37 allocs/op
BenchmarkCompression1kHits-12               648564   1928 ns/op   1384 B/op   15 allocs/op
BenchmarkCompression1kNocache-12           1965351    611 ns/op    312 B/op    6 allocs/op
BenchmarkCompression1kMisses-12             232980   5119 ns/op   3365 B/op   39 allocs/op
BenchmarkParallelCompression1kHits-12      2525994    511 ns/op   1383 B/op   15 allocs/op
BenchmarkParallelCompression1kNocache-12   3876728    335 ns/op    312 B/op    6 allocs/op
BenchmarkParallelCompression1kMisses-12     666580   2226 ns/op   3326 B/op   38 allocs/op
PASS
ok      github.com/kevburnsjr/microcache        7.188s
erikdubbelboer commented 5 years ago

You could maybe add a benchmark that does parallel requests using B.RunParallel. And a benchmark where the cache fills up and old entries have to be evicted to add new ones.

kevburnsjr commented 5 years ago

You could maybe add a benchmark that does parallel requests using B.RunParallel. And a benchmark where the cache fills up and old entries have to be evicted to add new ones.

Good idea. Done.