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

Function BenchmarkWriter

zapio/writer_test.go:193–231  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

191}
192
193func BenchmarkWriter(b *testing.B) {
194 tests := []struct {
195 name string
196 writes [][]byte
197 }{
198 {
199 name: "single",
200 writes: [][]byte{
201 []byte("foobar\n"),
202 []byte("bazqux\n"),
203 },
204 },
205 {
206 name: "splits",
207 writes: [][]byte{
208 []byte("foo"),
209 []byte("bar\nbaz"),
210 []byte("qux\n"),
211 },
212 },
213 }
214
215 writer := Writer{
216 Log: zap.New(new(partiallyNopCore)),
217 Level: zapcore.DebugLevel,
218 }
219
220 for _, tt := range tests {
221 b.Run(tt.name, func(b *testing.B) {
222 b.ResetTimer()
223
224 for i := 0; i < b.N; i++ {
225 for _, bs := range tt.writes {
226 writer.Write(bs)
227 }
228 }
229 })
230 }
231}
232
233// partiallyNopCore behaves exactly like NopCore except it always returns true
234// for whether the provided level is enabled, and accepts all Check requests.

Callers

nothing calls this directly

Calls 2

WriteMethod · 0.95
NewFunction · 0.92

Tested by

no test coverage detected