diff options
author | 2019-02-25 14:57:27 +0000 | |
---|---|---|
committer | 2019-02-25 06:57:27 -0800 | |
commit | 47cce40d199e320e8a36348a3b664aa998856976 (patch) | |
tree | 0697ce6c6e386f1124abcdc2de4f459f8535ad91 /plugin/errors/benchmark_test.go | |
parent | 780a433de82bb0fd4b56df392872aa8dcf6da3d9 (diff) | |
download | coredns-47cce40d199e320e8a36348a3b664aa998856976.tar.gz coredns-47cce40d199e320e8a36348a3b664aa998856976.tar.zst coredns-47cce40d199e320e8a36348a3b664aa998856976.zip |
Add benchmark test (#2610)
Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/errors/benchmark_test.go')
-rw-r--r-- | plugin/errors/benchmark_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/plugin/errors/benchmark_test.go b/plugin/errors/benchmark_test.go new file mode 100644 index 000000000..04e64332c --- /dev/null +++ b/plugin/errors/benchmark_test.go @@ -0,0 +1,27 @@ +package errors + +import ( + "context" + "testing" + + "github.com/coredns/coredns/plugin/test" + + "github.com/miekg/dns" +) + +func BenchmarkServeDNS(b *testing.B) { + h := &errorHandler{} + h.Next = test.ErrorHandler() + + r := new(dns.Msg) + r.SetQuestion("example.org.", dns.TypeA) + w := &test.ResponseWriter{} + ctx := context.TODO() + + for i := 0; i < b.N; i++ { + _, err := h.ServeDNS(ctx, w, r) + if err != nil { + b.Errorf("ServeDNS returned error: %s", err) + } + } +} |