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

Function BenchmarkStandardJSON

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

Source from the content-addressed store, hash-verified

98}
99
100func BenchmarkStandardJSON(b *testing.B) {
101 record := struct {
102 Level string `json:"level"`
103 Message string `json:"msg"`
104 Time time.Time `json:"ts"`
105 Fields map[string]interface{} `json:"fields"`
106 Additional StringSlice
107 }{
108 Level: "debug",
109 Message: "fake",
110 Time: time.Unix(0, 0),
111 Fields: map[string]interface{}{
112 "str": "foo",
113 "int64-1": int64(1),
114 "int64-2": int64(1),
115 "float64": float64(1.0),
116 "string1": "\n",
117 "string2": "💩",
118 "string3": "🤔",
119 "string4": "🙊",
120 "bool": true,
121 },
122 Additional: generateStringSlice(_sliceSize),
123 }
124 b.ResetTimer()
125 b.RunParallel(func(pb *testing.PB) {
126 for pb.Next() {
127 if _, err := json.Marshal(record); err != nil {
128 b.Fatal(err)
129 }
130 }
131 })
132}

Callers

nothing calls this directly

Calls 3

generateStringSliceFunction · 0.85
NextMethod · 0.80
FatalMethod · 0.45

Tested by

no test coverage detected