MCPcopy
hub / github.com/uber-go/zap / BenchmarkZapJSON

Function BenchmarkZapJSON

zapcore/json_encoder_bench_test.go:75–98  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

73}
74
75func BenchmarkZapJSON(b *testing.B) {
76 additional := generateStringSlice(_sliceSize)
77 b.ResetTimer()
78 b.RunParallel(func(pb *testing.PB) {
79 for pb.Next() {
80 enc := NewJSONEncoder(testEncoderConfig())
81 enc.AddString("str", "foo")
82 enc.AddInt64("int64-1", 1)
83 enc.AddInt64("int64-2", 2)
84 enc.AddFloat64("float64", 1.0)
85 enc.AddString("string1", "\n")
86 enc.AddString("string2", "💩")
87 enc.AddString("string3", "🤔")
88 enc.AddString("string4", "🙊")
89 enc.AddBool("bool", true)
90 _ = enc.AddArray("test", additional)
91 buf, _ := enc.EncodeEntry(Entry{
92 Message: "fake",
93 Level: DebugLevel,
94 }, nil)
95 buf.Free()
96 }
97 })
98}
99
100func BenchmarkStandardJSON(b *testing.B) {
101 record := struct {

Callers

nothing calls this directly

Calls 11

generateStringSliceFunction · 0.85
NewJSONEncoderFunction · 0.85
testEncoderConfigFunction · 0.85
NextMethod · 0.80
AddStringMethod · 0.65
AddInt64Method · 0.65
AddFloat64Method · 0.65
AddBoolMethod · 0.65
AddArrayMethod · 0.65
EncodeEntryMethod · 0.65
FreeMethod · 0.45

Tested by

no test coverage detected