mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 01:34:21 -04:00 
			
		
		
		
	
		
			
	
	
		
			28 lines
		
	
	
		
			461 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			28 lines
		
	
	
		
			461 B
		
	
	
	
		
			Go
		
	
	
	
	
	
|   | 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) | ||
|  | 		} | ||
|  | 	} | ||
|  | } |