MCPcopy
hub / github.com/op/go-logging / BenchmarkStringFormatter

Function BenchmarkStringFormatter

format_test.go:167–184  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

165}
166
167func BenchmarkStringFormatter(b *testing.B) {
168 fmt := "%{time:2006-01-02T15:04:05} %{level:.1s} %{id:04d} %{module} %{message}"
169 f := MustStringFormatter(fmt)
170
171 backend := InitForTesting(DEBUG)
172 buf := &bytes.Buffer{}
173 log := MustGetLogger("module")
174 log.Debug("")
175 record := MemoryRecordN(backend, 0)
176
177 b.ResetTimer()
178 for i := 0; i < b.N; i++ {
179 if err := f.Format(1, record, buf); err != nil {
180 b.Fatal(err)
181 buf.Truncate(0)
182 }
183 }
184}

Callers

nothing calls this directly

Calls 7

MustStringFormatterFunction · 0.85
InitForTestingFunction · 0.85
MustGetLoggerFunction · 0.85
MemoryRecordNFunction · 0.85
DebugMethod · 0.80
FatalMethod · 0.80
FormatMethod · 0.65

Tested by

no test coverage detected