mirror of
https://github.com/coredns/coredns.git
synced 2025-12-09 03:45:11 -05:00
Cache elements of State
Cache the size and the do bit whenever someone asked for it. We can probably add more: PASS BenchmarkStateDo-4 100000000 11.9 ns/op BenchmarkStateSize-4 5000000 265 ns/op ok github.com/miekg/coredns/middleware 2.828s PASS BenchmarkStateDo-4 1000000000 2.86 ns/op BenchmarkStateSize-4 500000000 3.10 ns/op ok github.com/miekg/coredns/middleware 5.032s This PR also includes some testing cleanups as well.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
@@ -79,24 +78,3 @@ func (r *ResponseRecorder) Hijack() {
|
||||
r.ResponseWriter.Hijack()
|
||||
return
|
||||
}
|
||||
|
||||
type TestResponseWriter struct{}
|
||||
|
||||
func (t *TestResponseWriter) LocalAddr() net.Addr {
|
||||
ip := net.ParseIP("127.0.0.1")
|
||||
port := 53
|
||||
return &net.UDPAddr{IP: ip, Port: port, Zone: ""}
|
||||
}
|
||||
|
||||
func (t *TestResponseWriter) RemoteAddr() net.Addr {
|
||||
ip := net.ParseIP("10.240.0.1")
|
||||
port := 40212
|
||||
return &net.UDPAddr{IP: ip, Port: port, Zone: ""}
|
||||
}
|
||||
|
||||
func (t *TestResponseWriter) WriteMsg(m *dns.Msg) error { return nil }
|
||||
func (t *TestResponseWriter) Write(buf []byte) (int, error) { return len(buf), nil }
|
||||
func (t *TestResponseWriter) Close() error { return nil }
|
||||
func (t *TestResponseWriter) TsigStatus() error { return nil }
|
||||
func (t *TestResponseWriter) TsigTimersOnly(bool) { return }
|
||||
func (t *TestResponseWriter) Hijack() { return }
|
||||
|
||||
Reference in New Issue
Block a user