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

Function BenchmarkSampler_Check

zapcore/sampler_bench_test.go:207–234  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

205}
206
207func BenchmarkSampler_Check(b *testing.B) {
208 for _, keys := range counterTestCases {
209 b.Run(fmt.Sprintf("%v keys", len(keys)), func(b *testing.B) {
210 fac := NewSamplerWithOptions(
211 NewCore(
212 NewJSONEncoder(testEncoderConfig()),
213 &ztest.Discarder{},
214 DebugLevel,
215 ),
216 time.Millisecond, 1, 1000)
217 b.ResetTimer()
218 b.RunParallel(func(pb *testing.PB) {
219 i := 0
220 for pb.Next() {
221 ent := Entry{
222 Level: DebugLevel + Level(i%4),
223 Message: keys[i],
224 }
225 _ = fac.Check(ent, nil)
226 i++
227 if n := len(keys); i >= n {
228 i -= n
229 }
230 }
231 })
232 })
233 }
234}
235
236func makeSamplerCountingHook() (func(_ Entry, dec SamplingDecision), *atomic.Int64, *atomic.Int64) {
237 droppedCount := new(atomic.Int64)

Callers

nothing calls this directly

Calls 7

NewSamplerWithOptionsFunction · 0.85
NewCoreFunction · 0.85
NewJSONEncoderFunction · 0.85
testEncoderConfigFunction · 0.85
NextMethod · 0.80
LevelTypeAlias · 0.70
CheckMethod · 0.65

Tested by

no test coverage detected