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

Function BenchmarkServer_LogRequest

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

Source from the content-addressed store, hash-verified

104}
105
106func BenchmarkServer_LogRequest(b *testing.B) {
107 s := &Server{}
108
109 extra := new(ExtraLogFields)
110 ctx := context.WithValue(context.Background(), ExtraLogFieldsCtxKey, extra)
111
112 req := httptest.NewRequest(http.MethodGet, "/", nil).WithContext(ctx)
113 rec := httptest.NewRecorder()
114 wrec := NewResponseRecorder(rec, nil, nil)
115
116 duration := 50 * time.Millisecond
117 repl := NewTestReplacer(req)
118 bodyReader := &lengthReader{Source: req.Body}
119
120 buf := io.Discard
121 accLog := testLogger(buf.Write)
122
123 for b.Loop() {
124 s.logRequest(accLog, req, wrec, &duration, repl, bodyReader, false)
125 }
126}
127
128func BenchmarkServer_LogRequest_NopLogger(b *testing.B) {
129 s := &Server{}

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected