(b *testing.B)
| 574 | } |
| 575 | |
| 576 | func BenchmarkMetricsInstrumentedRoute(b *testing.B) { |
| 577 | ctx, _ := caddy.NewContext(caddy.Context{Context: context.Background()}) |
| 578 | m := &Metrics{ |
| 579 | init: sync.Once{}, |
| 580 | httpMetrics: &httpMetrics{}, |
| 581 | } |
| 582 | |
| 583 | noopHandler := HandlerFunc(func(w http.ResponseWriter, r *http.Request) error { |
| 584 | w.Write([]byte("ok")) |
| 585 | return nil |
| 586 | }) |
| 587 | |
| 588 | ih := newMetricsInstrumentedRoute(ctx, "bench_handler", noopHandler, m) |
| 589 | |
| 590 | r := httptest.NewRequest("GET", "/", nil) |
| 591 | w := httptest.NewRecorder() |
| 592 | |
| 593 | b.ResetTimer() |
| 594 | b.ReportAllocs() |
| 595 | for i := 0; i < b.N; i++ { |
| 596 | ih.ServeHTTP(w, r) |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | // BenchmarkSingleRouteMetrics simulates the new behavior where metrics |
| 601 | // are collected once for the entire route. |
nothing calls this directly
no test coverage detected