MCPcopy
hub / github.com/keploy/keploy / BenchmarkAddDebugFileSink_Write

Function BenchmarkAddDebugFileSink_Write

utils/log/logger_test.go:513–531  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

511}
512
513func BenchmarkAddDebugFileSink_Write(b *testing.B) {
514 SetRedactor(nil)
515 console := &syncBuffer{}
516 base := newConsoleLogger(console, zap.InfoLevel)
517
518 tmpDir := b.TempDir()
519 tmp, err := os.OpenFile(filepath.Join(tmpDir, "bench.log"), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644)
520 if err != nil {
521 b.Fatalf("open: %v", err)
522 }
523 defer tmp.Close()
524 wrapped, sink := AddDebugFileSink(base, tmp, 0)
525 defer sink.Flush()
526
527 b.ResetTimer()
528 for i := 0; i < b.N; i++ {
529 wrapped.Debug("bench", zap.Int("i", i), zap.String("k", "value"))
530 }
531}
532
533func BenchmarkBaseline_Write(b *testing.B) {
534 SetRedactor(nil)

Callers

nothing calls this directly

Calls 7

SetRedactorFunction · 0.85
newConsoleLoggerFunction · 0.85
AddDebugFileSinkFunction · 0.85
FlushMethod · 0.80
CloseMethod · 0.65
DebugMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected