diff options
author | 2017-10-23 17:24:48 +0100 | |
---|---|---|
committer | 2017-10-23 17:24:48 +0100 | |
commit | 5aa0d55e72cda8ac4cf95b67b051959b91d8f183 (patch) | |
tree | 33872379ce4b4153487a074d5b8f25170a938c0c /plugin/pkg/cache/cache_test.go | |
parent | cb5e82b82eb85b49be8bb8747f3475b8d76d57e1 (diff) | |
download | coredns-5aa0d55e72cda8ac4cf95b67b051959b91d8f183.tar.gz coredns-5aa0d55e72cda8ac4cf95b67b051959b91d8f183.tar.zst coredns-5aa0d55e72cda8ac4cf95b67b051959b91d8f183.zip |
plugin/pkg/cache: smarter locking (#1164)
Make the locking slightly smarter in Evict and add benchmark function.
Seems a bit faster (there was some variance while performing these
benchmarks)
Master:
BenchmarkCache-2 1000000 2317 ns/op 0 B/op 0 allocs/op
BenchmarkCache-2 1000000 2032 ns/op 0 B/op 0 allocs/op
This branch:
BenchmarkCache-2 1000000 1806 ns/op 0 B/op 0 allocs/op
BenchmarkCache-2 1000000 1809 ns/op 0 B/op 0 allocs/op
Diffstat (limited to 'plugin/pkg/cache/cache_test.go')
-rw-r--r-- | plugin/pkg/cache/cache_test.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/plugin/pkg/cache/cache_test.go b/plugin/pkg/cache/cache_test.go index 2c92bf438..0c56bb9b3 100644 --- a/plugin/pkg/cache/cache_test.go +++ b/plugin/pkg/cache/cache_test.go @@ -29,3 +29,13 @@ func TestCacheLen(t *testing.T) { t.Fatalf("Cache size should %d, got %d", 2, l) } } + +func BenchmarkCache(b *testing.B) { + b.ReportAllocs() + + c := New(4) + for n := 0; n < b.N; n++ { + c.Add(1, 1) + c.Get(1) + } +} |