mirror of
https://github.com/coredns/coredns.git
synced 2025-11-02 02:03:13 -05:00
Add Benchmark functions
Add benchmark for normal and DNSSEC lookup. We can probably shave quite a lot of these, but first lets actually get to something that is serving.
This commit is contained in:
@@ -4,4 +4,4 @@ go:
|
|||||||
- 1.5
|
- 1.5
|
||||||
- 1.6
|
- 1.6
|
||||||
script:
|
script:
|
||||||
- go test -race -bench=./... ./...
|
- go test -race -bench=. ./...
|
||||||
|
|||||||
@@ -156,6 +156,38 @@ func TestLookupDNSSEC(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkLookupDNSSEC(b *testing.B) {
|
||||||
|
zone, err := Parse(strings.NewReader(dbMiekNL_signed), testzone, "stdin")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fm := File{Next: coretest.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}}
|
||||||
|
ctx := context.TODO()
|
||||||
|
rec := middleware.NewResponseRecorder(&middleware.TestResponseWriter{})
|
||||||
|
|
||||||
|
tc := coretest.Case{
|
||||||
|
Qname: "b.miek.nl.", Qtype: dns.TypeA, Do: true,
|
||||||
|
Rcode: dns.RcodeNameError,
|
||||||
|
Ns: []dns.RR{
|
||||||
|
coretest.NSEC("archive.miek.nl. 14400 IN NSEC go.dns.miek.nl. CNAME RRSIG NSEC"),
|
||||||
|
coretest.RRSIG("archive.miek.nl. 14400 IN RRSIG NSEC 8 3 14400 20160426031301 20160327031301 12051 miek.nl. jEpx8lcp4do5fWXg="),
|
||||||
|
coretest.NSEC("miek.nl. 14400 IN NSEC a.miek.nl. A NS SOA MX AAAA RRSIG NSEC DNSKEY"),
|
||||||
|
coretest.RRSIG("miek.nl. 14400 IN RRSIG NSEC 8 2 14400 20160426031301 20160327031301 12051 miek.nl. mFfc3r/9PSC1H6oSpdC"),
|
||||||
|
coretest.RRSIG("miek.nl. 1800 IN RRSIG SOA 8 2 1800 20160426031301 20160327031301 12051 miek.nl. FIrzy07acBbtyQczy1dc="),
|
||||||
|
coretest.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
m := tc.Msg()
|
||||||
|
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
fm.ServeDNS(ctx, rec, m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const dbMiekNL_signed = `
|
const dbMiekNL_signed = `
|
||||||
; File written on Sun Mar 27 04:13:01 2016
|
; File written on Sun Mar 27 04:13:01 2016
|
||||||
; dnssec_signzone version 9.10.3-P4-Ubuntu
|
; dnssec_signzone version 9.10.3-P4-Ubuntu
|
||||||
|
|||||||
@@ -13,6 +13,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var dnsTestCases = []coretest.Case{
|
var dnsTestCases = []coretest.Case{
|
||||||
|
{
|
||||||
|
Qname: "www.miek.nl.", Qtype: dns.TypeA,
|
||||||
|
Answer: []dns.RR{
|
||||||
|
coretest.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."),
|
||||||
|
},
|
||||||
|
|
||||||
|
Extra: []dns.RR{
|
||||||
|
coretest.A("a.miek.nl. 1800 IN A 139.162.196.78"),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Qname: "miek.nl.", Qtype: dns.TypeSOA,
|
Qname: "miek.nl.", Qtype: dns.TypeSOA,
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
@@ -35,16 +45,6 @@ var dnsTestCases = []coretest.Case{
|
|||||||
coretest.MX("miek.nl. 1800 IN MX 5 alt2.aspmx.l.google.com."),
|
coretest.MX("miek.nl. 1800 IN MX 5 alt2.aspmx.l.google.com."),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Qname: "www.miek.nl.", Qtype: dns.TypeA,
|
|
||||||
Answer: []dns.RR{
|
|
||||||
coretest.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."),
|
|
||||||
},
|
|
||||||
|
|
||||||
Extra: []dns.RR{
|
|
||||||
coretest.A("a.miek.nl. 1800 IN A 139.162.196.78"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Qname: "a.miek.nl.", Qtype: dns.TypeSRV,
|
Qname: "a.miek.nl.", Qtype: dns.TypeSRV,
|
||||||
Ns: []dns.RR{
|
Ns: []dns.RR{
|
||||||
@@ -124,6 +124,36 @@ func TestLookup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkLookup(b *testing.B) {
|
||||||
|
zone, err := Parse(strings.NewReader(dbMiekNL), testzone, "stdin")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fm := File{Next: coretest.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}}
|
||||||
|
ctx := context.TODO()
|
||||||
|
rec := middleware.NewResponseRecorder(&middleware.TestResponseWriter{})
|
||||||
|
|
||||||
|
tc := coretest.Case{
|
||||||
|
Qname: "www.miek.nl.", Qtype: dns.TypeA,
|
||||||
|
Answer: []dns.RR{
|
||||||
|
coretest.CNAME("www.miek.nl. 1800 IN CNAME a.miek.nl."),
|
||||||
|
},
|
||||||
|
|
||||||
|
Extra: []dns.RR{
|
||||||
|
coretest.A("a.miek.nl. 1800 IN A 139.162.196.78"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
m := tc.Msg()
|
||||||
|
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
fm.ServeDNS(ctx, rec, m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const dbMiekNL = `
|
const dbMiekNL = `
|
||||||
$TTL 30M
|
$TTL 30M
|
||||||
$ORIGIN miek.nl.
|
$ORIGIN miek.nl.
|
||||||
|
|||||||
Reference in New Issue
Block a user