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

Function BenchmarkBufferedWriteSyncer

zapcore/buffered_write_syncer_bench_test.go:31–55  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

29)
30
31func BenchmarkBufferedWriteSyncer(b *testing.B) {
32 b.Run("write file with buffer", func(b *testing.B) {
33 file, err := os.CreateTemp(b.TempDir(), "test.log")
34 require.NoError(b, err)
35
36 defer func() {
37 assert.NoError(b, file.Close())
38 }()
39
40 w := &BufferedWriteSyncer{
41 WS: AddSync(file),
42 }
43 defer func() {
44 assert.NoError(b, w.Stop(), "failed to stop buffered write syncer")
45 }()
46 b.ResetTimer()
47 b.RunParallel(func(pb *testing.PB) {
48 for pb.Next() {
49 if _, err := w.Write([]byte("foobarbazbabble")); err != nil {
50 b.Fatal(err)
51 }
52 }
53 })
54 })
55}

Callers

nothing calls this directly

Calls 6

StopMethod · 0.95
WriteMethod · 0.95
AddSyncFunction · 0.85
NextMethod · 0.80
CloseMethod · 0.45
FatalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…