(b *testing.B)
| 104 | } |
| 105 | |
| 106 | func 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 | |
| 128 | func BenchmarkServer_LogRequest_NopLogger(b *testing.B) { |
| 129 | s := &Server{} |
nothing calls this directly
no test coverage detected