MCPcopy
hub / github.com/rs/zerolog / BenchmarkDataRace

Function BenchmarkDataRace

hlog/hlog_test.go:351–369  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

349}
350
351func BenchmarkDataRace(b *testing.B) {
352 log := zerolog.New(nil).With().
353 Str("foo", "bar").
354 Logger()
355 lh := NewHandler(log)
356 h := lh(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
357 l := FromRequest(r)
358 l.UpdateContext(func(c zerolog.Context) zerolog.Context {
359 return c.Str("bar", "baz")
360 })
361 l.Log().Msg("")
362 }))
363
364 b.RunParallel(func(pb *testing.PB) {
365 for pb.Next() {
366 h.ServeHTTP(nil, &http.Request{})
367 }
368 })
369}
370
371func TestCtxWithID(t *testing.T) {
372 ctx := context.Background()

Callers

nothing calls this directly

Calls 10

NewFunction · 0.92
NewHandlerFunction · 0.85
FromRequestFunction · 0.85
LoggerMethod · 0.80
WithMethod · 0.80
UpdateContextMethod · 0.80
MsgMethod · 0.80
LogMethod · 0.65
NextMethod · 0.65
StrMethod · 0.45

Tested by

no test coverage detected