aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/server_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/server_test.go')
-rw-r--r--modules/caddyhttp/server_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/caddyhttp/server_test.go b/modules/caddyhttp/server_test.go
index d382a6963..2c8033d45 100644
--- a/modules/caddyhttp/server_test.go
+++ b/modules/caddyhttp/server_test.go
@@ -121,6 +121,29 @@ func BenchmarkServer_LogRequest(b *testing.B) {
}
}
+func BenchmarkServer_LogRequest_NopLogger(b *testing.B) {
+ s := &Server{}
+
+ extra := new(ExtraLogFields)
+ ctx := context.WithValue(context.Background(), ExtraLogFieldsCtxKey, extra)
+
+ req := httptest.NewRequest(http.MethodGet, "/", nil).WithContext(ctx)
+ rec := httptest.NewRecorder()
+ wrec := NewResponseRecorder(rec, nil, nil)
+
+ duration := 50 * time.Millisecond
+ repl := NewTestReplacer(req)
+ bodyReader := &lengthReader{Source: req.Body}
+
+ accLog := zap.NewNop()
+
+ b.ResetTimer()
+
+ for i := 0; i < b.N; i++ {
+ s.logRequest(accLog, req, wrec, &duration, repl, bodyReader, false)
+ }
+}
+
func BenchmarkServer_LogRequest_WithTraceID(b *testing.B) {
s := &Server{}