MCPcopy
hub / github.com/grafana/dskit / BenchmarkLazySprintf

Function BenchmarkLazySprintf

log/gokit_test.go:19–33  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

17)
18
19func BenchmarkLazySprintf(b *testing.B) {
20 g := log.NewNopLogger()
21 logger := level.NewFilter(addStandardFields(g), level.AllowInfo())
22 // Simulate the parameters used in middleware/logging.go
23 var (
24 method = "method"
25 uri = "https://example.com/foobar"
26 statusCode = 404
27 duration = 42
28 )
29 b.ResetTimer()
30 for i := 0; i < b.N; i++ {
31 level.Debug(logger).Log("msg", LazySprintf("%s %s (%d) %v", method, uri, statusCode, duration))
32 }
33}
34
35func TestLazySprintf(t *testing.T) {
36 tests := map[string]struct {

Callers

nothing calls this directly

Calls 3

addStandardFieldsFunction · 0.85
LazySprintfFunction · 0.85
LogMethod · 0.45

Tested by

no test coverage detected