MCPcopy
hub / github.com/gofiber/fiber / Benchmark_LogfKeyAndValues_Parallel

Function Benchmark_LogfKeyAndValues_Parallel

log/default_test.go:612–668  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

610}
611
612func Benchmark_LogfKeyAndValues_Parallel(b *testing.B) {
613 tests := []struct {
614 name string
615 format string
616 keysAndValues []any
617 level Level
618 }{
619 {
620 name: "debug level with key-values",
621 level: LevelDebug,
622 format: "",
623 keysAndValues: []any{"name", "Bob", "age", 30},
624 },
625 {
626 name: "info level with key-values",
627 level: LevelInfo,
628 format: "",
629 keysAndValues: []any{"status", "ok", "code", 200},
630 },
631 {
632 name: "warn level with key-values",
633 level: LevelWarn,
634 format: "",
635 keysAndValues: []any{"error", "not found", "id", 123},
636 },
637 {
638 name: "warn level with format and key-values",
639 level: LevelWarn,
640 format: "test",
641 keysAndValues: []any{"error", "not found", "id", 123},
642 },
643 {
644 name: "warn level with one key",
645 level: LevelWarn,
646 format: "",
647 keysAndValues: []any{"error"},
648 },
649 }
650
651 for _, tt := range tests {
652 b.Run(tt.name, func(bb *testing.B) {
653 bb.ReportAllocs()
654 bb.ResetTimer()
655 bb.RunParallel(func(pb *testing.PB) {
656 var buf bytes.Buffer
657 l := &defaultLogger{
658 stdlog: log.New(&buf, "", 0),
659 level: tt.level,
660 depth: 4,
661 }
662 for pb.Next() {
663 l.privateLogw(tt.level, tt.format, tt.keysAndValues)
664 }
665 })
666 })
667 }
668}

Callers

nothing calls this directly

Calls 3

privateLogwMethod · 0.95
NewMethod · 0.65
NextMethod · 0.65

Tested by

no test coverage detected