(b *testing.B, wrappings int)
| 19 | } |
| 20 | |
| 21 | func benchmark(b *testing.B, wrappings int) { |
| 22 | dummyH := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) |
| 23 | h := dummyH |
| 24 | for x := 0; x < wrappings; x++ { |
| 25 | hCopy := h |
| 26 | h = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 27 | CaptureMetrics(hCopy, w, r) |
| 28 | }) |
| 29 | } |
| 30 | |
| 31 | req := httptest.NewRequest(http.MethodGet, "/", http.NoBody) |
| 32 | resp := httptest.NewRecorder() // ok to reuse; we're not writing anything to it |
| 33 | |
| 34 | b.ReportAllocs() |
| 35 | b.ResetTimer() |
| 36 | |
| 37 | for i := 0; i < b.N; i++ { |
| 38 | h.ServeHTTP(resp, req) |
| 39 | } |
| 40 | } |
no test coverage detected
searching dependent graphs…