(b *testing.B)
| 323 | } |
| 324 | |
| 325 | func BenchmarkHandlers(b *testing.B) { |
| 326 | r := &http.Request{ |
| 327 | Method: "POST", |
| 328 | URL: &url.URL{Path: "/path", RawQuery: "foo=bar"}, |
| 329 | } |
| 330 | h1 := URLHandler("url")(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 331 | l := FromRequest(r) |
| 332 | l.Log().Msg("") |
| 333 | })) |
| 334 | h2 := MethodHandler("method")(RequestHandler("request")(h1)) |
| 335 | handlers := map[string]http.Handler{ |
| 336 | "Single": NewHandler(zerolog.New(io.Discard))(h1), |
| 337 | "Combined": NewHandler(zerolog.New(io.Discard))(h2), |
| 338 | "SingleDisabled": NewHandler(zerolog.New(io.Discard).Level(zerolog.Disabled))(h1), |
| 339 | "CombinedDisabled": NewHandler(zerolog.New(io.Discard).Level(zerolog.Disabled))(h2), |
| 340 | } |
| 341 | for name := range handlers { |
| 342 | h := handlers[name] |
| 343 | b.Run(name, func(b *testing.B) { |
| 344 | for i := 0; i < b.N; i++ { |
| 345 | h.ServeHTTP(nil, r) |
| 346 | } |
| 347 | }) |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | func BenchmarkDataRace(b *testing.B) { |
| 352 | log := zerolog.New(nil).With(). |
nothing calls this directly
no test coverage detected