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

Function BenchmarkMultiWriteSyncer

zapcore/write_syncer_bench_test.go:32–84  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

30)
31
32func BenchmarkMultiWriteSyncer(b *testing.B) {
33 b.Run("2 discarder", func(b *testing.B) {
34 w := NewMultiWriteSyncer(
35 &ztest.Discarder{},
36 &ztest.Discarder{},
37 )
38 b.ResetTimer()
39 b.RunParallel(func(pb *testing.PB) {
40 for pb.Next() {
41 if _, err := w.Write([]byte("foobarbazbabble")); err != nil {
42 b.Fatal(err)
43 }
44 }
45 })
46 })
47 b.Run("4 discarder", func(b *testing.B) {
48 w := NewMultiWriteSyncer(
49 &ztest.Discarder{},
50 &ztest.Discarder{},
51 &ztest.Discarder{},
52 &ztest.Discarder{},
53 )
54 b.ResetTimer()
55 b.RunParallel(func(pb *testing.PB) {
56 for pb.Next() {
57 if _, err := w.Write([]byte("foobarbazbabble")); err != nil {
58 b.Fatal(err)
59 }
60 }
61 })
62 })
63 b.Run("4 discarder with buffer", func(b *testing.B) {
64 w := &BufferedWriteSyncer{
65 WS: NewMultiWriteSyncer(
66 &ztest.Discarder{},
67 &ztest.Discarder{},
68 &ztest.Discarder{},
69 &ztest.Discarder{},
70 ),
71 }
72 defer func() {
73 assert.NoError(b, w.Stop(), "Unexpected error stopping buffered write syncer.")
74 }()
75 b.ResetTimer()
76 b.RunParallel(func(pb *testing.PB) {
77 for pb.Next() {
78 if _, err := w.Write([]byte("foobarbazbabble")); err != nil {
79 b.Fatal(err)
80 }
81 }
82 })
83 })
84}
85
86func BenchmarkWriteSyncer(b *testing.B) {
87 b.Run("write file with no buffer", func(b *testing.B) {

Callers

nothing calls this directly

Calls 5

WriteMethod · 0.95
StopMethod · 0.95
NewMultiWriteSyncerFunction · 0.85
NextMethod · 0.80
FatalMethod · 0.45

Tested by

no test coverage detected