MCPcopy
hub / github.com/caddyserver/caddy / BenchmarkServer_LogRequest_NopLogger

Function BenchmarkServer_LogRequest_NopLogger

modules/caddyhttp/server_test.go:128–147  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

126}
127
128func BenchmarkServer_LogRequest_NopLogger(b *testing.B) {
129 s := &Server{}
130
131 extra := new(ExtraLogFields)
132 ctx := context.WithValue(context.Background(), ExtraLogFieldsCtxKey, extra)
133
134 req := httptest.NewRequest(http.MethodGet, "/", nil).WithContext(ctx)
135 rec := httptest.NewRecorder()
136 wrec := NewResponseRecorder(rec, nil, nil)
137
138 duration := 50 * time.Millisecond
139 repl := NewTestReplacer(req)
140 bodyReader := &lengthReader{Source: req.Body}
141
142 accLog := zap.NewNop()
143
144 for b.Loop() {
145 s.logRequest(accLog, req, wrec, &duration, repl, bodyReader, false)
146 }
147}
148
149func BenchmarkServer_LogRequest_WithTrace(b *testing.B) {
150 s := &Server{}

Callers

nothing calls this directly

Calls 4

logRequestMethod · 0.95
NewResponseRecorderFunction · 0.85
NewTestReplacerFunction · 0.85
WithValueMethod · 0.80

Tested by

no test coverage detected