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

Function BenchmarkContextFieldType

benchmark_test.go:236–372  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

234}
235
236func BenchmarkContextFieldType(b *testing.B) {
237 oldFormat := TimeFieldFormat
238 TimeFieldFormat = TimeFormatUnix
239 defer func() { TimeFieldFormat = oldFormat }()
240
241 fixtures := makeFieldFixtures()
242 types := map[string]func(c Context) Context{
243 "Any": func(c Context) Context {
244 return c.Any("k", fixtures.Interfaces[0])
245 },
246 "Bool": func(c Context) Context {
247 return c.Bool("k", fixtures.Bools[0])
248 },
249 "Bools": func(c Context) Context {
250 return c.Bools("k", fixtures.Bools)
251 },
252 "Bytes": func(c Context) Context {
253 return c.Bytes("k", fixtures.Bytes)
254 },
255 "Hex": func(c Context) Context {
256 return c.Hex("k", fixtures.Bytes)
257 },
258 "Int": func(c Context) Context {
259 return c.Int("k", fixtures.Ints[0])
260 },
261 "Ints": func(c Context) Context {
262 return c.Ints("k", fixtures.Ints)
263 },
264 "Float32": func(c Context) Context {
265 return c.Float32("k", fixtures.Floats32[0])
266 },
267 "Floats32": func(c Context) Context {
268 return c.Floats32("k", fixtures.Floats32)
269 },
270 "Float64": func(c Context) Context {
271 return c.Float64("k", fixtures.Floats64[0])
272 },
273 "Floats64": func(c Context) Context {
274 return c.Floats64("k", fixtures.Floats64)
275 },
276 "Str": func(c Context) Context {
277 return c.Str("k", fixtures.Strings[0])
278 },
279 "Strs": func(c Context) Context {
280 return c.Strs("k", fixtures.Strings)
281 },
282 "StrsV": func(c Context) Context {
283 return c.StrsV("k", fixtures.Strings...)
284 },
285 "Stringer": func(c Context) Context {
286 return c.Stringer("k", fixtures.Stringers[0])
287 },
288 "Stringers": func(c Context) Context {
289 return c.Stringers("k", fixtures.Stringers)
290 },
291 "StringersV": func(c Context) Context {
292 return c.StringersV("k", fixtures.Stringers...)
293 },

Callers

nothing calls this directly

Calls 15

makeFieldFixturesFunction · 0.85
NewFunction · 0.85
LoggerMethod · 0.80
WithMethod · 0.80
MsgMethod · 0.80
ErrMethod · 0.65
RunMethod · 0.65
NextMethod · 0.65
InfoMethod · 0.65
AnyMethod · 0.45
BoolMethod · 0.45
BoolsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…