aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/cache_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-10-29 15:13:39 +0000
committerGravatar Yong Tang <yong.tang.github@outlook.com> 2018-10-29 08:13:39 -0700
commite6d02a3fd25831fc68e5c6f2bf9b779098ef8b98 (patch)
tree305823ab8d1ba4e0e156209367cc4d201cd59c87 /plugin/cache/cache_test.go
parent29f42053643325bf0c23ae8da47362ea1a7650e0 (diff)
downloadcoredns-e6d02a3fd25831fc68e5c6f2bf9b779098ef8b98.tar.gz
coredns-e6d02a3fd25831fc68e5c6f2bf9b779098ef8b98.tar.zst
coredns-e6d02a3fd25831fc68e5c6f2bf9b779098ef8b98.zip
cache: some optimizations (#2247)
Remove some optimization and lowercasing of the qname (in the end miekg/dns should provide a fast and OK function for it). * remove the make([]byte, 2) allocation in the key() * use already lowercased qname in hash key calculation. % benchcmp old.txt new.txt benchmark old ns/op new ns/op delta BenchmarkCacheResponse-4 9599 8735 -9.00% Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/cache/cache_test.go')
-rw-r--r--plugin/cache/cache_test.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/plugin/cache/cache_test.go b/plugin/cache/cache_test.go
index 6ef8c8c3a..4b71e9122 100644
--- a/plugin/cache/cache_test.go
+++ b/plugin/cache/cache_test.go
@@ -167,7 +167,7 @@ func TestCache(t *testing.T) {
state := request.Request{W: nil, Req: m}
mt, _ := response.Typify(m, utc)
- valid, k := key(m, mt, state.Do())
+ valid, k := key(state.Name(), m, mt, state.Do())
if valid {
crr.set(m, k, mt, c.pttl)
@@ -241,8 +241,7 @@ func BenchmarkCacheResponse(b *testing.B) {
for i := 0; i < b.N; i++ {
req := reqs[j]
c.ServeDNS(ctx, &test.ResponseWriter{}, req)
- j++
- j = j % 5
+ j = (j + 1) % 5
}
}