Debian Codegraph @

zapcore/write_syncer_bench_test.go

raw symbols SCIP
1 // Copyright (c) 2016 Uber Technologies, Inc.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20
21 package zapcorescip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/
22
23 import (
24 "osscip-go gomod github.com/golang/go/src go1.19 os/"
25 "testingscip-go gomod github.com/golang/go/src go1.19 testing/"
26
27 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/"
28 "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/require`/"
29 "go.uber.org/zap/internal/ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/"
30 )
31
32 func BenchmarkMultiWriteSyncerscip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/BenchmarkMultiWriteSyncer().(b *testingscip-go gomod github.com/golang/go/src go1.19 testing/.Bscip-go gomod github.com/golang/go/src go1.19 testing/B#) {
33 b.Runscip-go gomod github.com/golang/go/src go1.19 testing/B#Run().("2 discarder", func(b *testingscip-go gomod github.com/golang/go/src go1.19 testing/.Bscip-go gomod github.com/golang/go/src go1.19 testing/B#) {
34 w := NewMultiWriteSyncerscip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/NewMultiWriteSyncer().(
35 &ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/.Discarderscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/Discarder#{},
36 &ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/.Discarderscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/Discarder#{},
37 )
38 b.ResetTimerscip-go gomod github.com/golang/go/src go1.19 testing/B#ResetTimer().()
39 b.RunParallelscip-go gomod github.com/golang/go/src go1.19 testing/B#RunParallel().(func(pb *testingscip-go gomod github.com/golang/go/src go1.19 testing/.PBscip-go gomod github.com/golang/go/src go1.19 testing/PB#) {
40 for pb.Nextscip-go gomod github.com/golang/go/src go1.19 testing/PB#Next().() {
41 if _, err := w.Writescip-go gomod github.com/golang/go/src go1.19 io/Writer#Write().([]byte("foobarbazbabble")); err != nil {
42 b.Fatalscip-go gomod github.com/golang/go/src go1.19 testing/common#Fatal().(err)
43 }
44 }
45 })
46 })
47 b.Runscip-go gomod github.com/golang/go/src go1.19 testing/B#Run().("4 discarder", func(b *testingscip-go gomod github.com/golang/go/src go1.19 testing/.Bscip-go gomod github.com/golang/go/src go1.19 testing/B#) {
48 w := NewMultiWriteSyncerscip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/NewMultiWriteSyncer().(
49 &ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/.Discarderscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/Discarder#{},
50 &ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/.Discarderscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/Discarder#{},
51 &ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/.Discarderscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/Discarder#{},
52 &ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/.Discarderscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/Discarder#{},
53 )
54 b.ResetTimerscip-go gomod github.com/golang/go/src go1.19 testing/B#ResetTimer().()
55 b.RunParallelscip-go gomod github.com/golang/go/src go1.19 testing/B#RunParallel().(func(pb *testingscip-go gomod github.com/golang/go/src go1.19 testing/.PBscip-go gomod github.com/golang/go/src go1.19 testing/PB#) {
56 for pb.Nextscip-go gomod github.com/golang/go/src go1.19 testing/PB#Next().() {
57 if _, err := w.Writescip-go gomod github.com/golang/go/src go1.19 io/Writer#Write().([]byte("foobarbazbabble")); err != nil {
58 b.Fatalscip-go gomod github.com/golang/go/src go1.19 testing/common#Fatal().(err)
59 }
60 }
61 })
62 })
63 b.Runscip-go gomod github.com/golang/go/src go1.19 testing/B#Run().("4 discarder with buffer", func(b *testingscip-go gomod github.com/golang/go/src go1.19 testing/.Bscip-go gomod github.com/golang/go/src go1.19 testing/B#) {
64 w := &BufferedWriteSyncerscip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/BufferedWriteSyncer#{
65 WSscip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/BufferedWriteSyncer#WS.: NewMultiWriteSyncerscip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/NewMultiWriteSyncer().(
66 &ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/.Discarderscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/Discarder#{},
67 &ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/.Discarderscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/Discarder#{},
68 &ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/.Discarderscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/Discarder#{},
69 &ztestscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/.Discarderscip-go gomod go.uber.org/zap . `go.uber.org/zap/internal/ztest`/Discarder#{},
70 ),
71 }
72 defer func() {
73 assertscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/assert`/NoError().(b, w.Stopscip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/BufferedWriteSyncer#Stop().(), "Unexpected error stopping buffered write syncer.")
74 }()
75 b.ResetTimerscip-go gomod github.com/golang/go/src go1.19 testing/B#ResetTimer().()
76 b.RunParallelscip-go gomod github.com/golang/go/src go1.19 testing/B#RunParallel().(func(pb *testingscip-go gomod github.com/golang/go/src go1.19 testing/.PBscip-go gomod github.com/golang/go/src go1.19 testing/PB#) {
77 for pb.Nextscip-go gomod github.com/golang/go/src go1.19 testing/PB#Next().() {
78 if _, err := w.Writescip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/BufferedWriteSyncer#Write().([]byte("foobarbazbabble")); err != nil {
79 b.Fatalscip-go gomod github.com/golang/go/src go1.19 testing/common#Fatal().(err)
80 }
81 }
82 })
83 })
84 }
85
86 func BenchmarkWriteSyncerscip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/BenchmarkWriteSyncer().(b *testingscip-go gomod github.com/golang/go/src go1.19 testing/.Bscip-go gomod github.com/golang/go/src go1.19 testing/B#) {
87 b.Runscip-go gomod github.com/golang/go/src go1.19 testing/B#Run().("write file with no buffer", func(b *testingscip-go gomod github.com/golang/go/src go1.19 testing/.Bscip-go gomod github.com/golang/go/src go1.19 testing/B#) {
88 file, err := osscip-go gomod github.com/golang/go/src go1.19 os/.CreateTempscip-go gomod github.com/golang/go/src go1.19 os/CreateTemp().(b.TempDirscip-go gomod github.com/golang/go/src go1.19 testing/common#TempDir().(), "test.log")
89 requirescip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.1 `github.com/stretchr/testify/require`/NoError().(b, err)
90
91 w := AddSyncscip-go gomod go.uber.org/zap . `go.uber.org/zap/zapcore`/AddSync().(file)
92 b.ResetTimerscip-go gomod github.com/golang/go/src go1.19 testing/B#ResetTimer().()
93 b.RunParallelscip-go gomod github.com/golang/go/src go1.19 testing/B#RunParallel().(func(pb *testingscip-go gomod github.com/golang/go/src go1.19 testing/.PBscip-go gomod github.com/golang/go/src go1.19 testing/PB#) {
94 for pb.Nextscip-go gomod github.com/golang/go/src go1.19 testing/PB#Next().() {
95 if _, err := w.Writescip-go gomod github.com/golang/go/src go1.19 io/Writer#Write().([]byte("foobarbazbabble")); err != nil {
96 b.Fatalscip-go gomod github.com/golang/go/src go1.19 testing/common#Fatal().(err)
97 }
98 }
99 })
100 })
101 }