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

Function BenchmarkSpanLogger

spanlogger/spanlogger_test.go:20–39  ·  view source on GitHub ↗

Using a no-op logger and no tracing provider, measure the overhead of a small log call.

(b *testing.B)

Source from the content-addressed store, hash-verified

18
19// Using a no-op logger and no tracing provider, measure the overhead of a small log call.
20func BenchmarkSpanLogger(b *testing.B) {
21 logger := noDebugNoopLogger{}
22 resolver := tenant.NewMultiResolver()
23 sl, _ := New(context.Background(), logger, "test", resolver, "bar")
24 b.Run("log", func(b *testing.B) {
25 for i := 0; i < b.N; i++ {
26 _ = sl.Log("msg", "foo", "more", "data")
27 }
28 })
29 b.Run("level.debug", func(b *testing.B) {
30 for i := 0; i < b.N; i++ {
31 _ = level.Debug(sl).Log("msg", "foo", "more", "data")
32 }
33 })
34 b.Run("debuglog", func(b *testing.B) {
35 for i := 0; i < b.N; i++ {
36 sl.DebugLog("msg", "foo", "more", "data")
37 }
38 })
39}
40
41func BenchmarkSpanLoggerWithRealLogger(b *testing.B) {
42 testCases := map[string]bool{

Callers

nothing calls this directly

Calls 5

NewMultiResolverFunction · 0.92
RunMethod · 0.80
DebugLogMethod · 0.80
NewFunction · 0.70
LogMethod · 0.45

Tested by

no test coverage detected