Using a no-op logger and no tracing provider, measure the overhead of a small log call.
(b *testing.B)
| 18 | |
| 19 | // Using a no-op logger and no tracing provider, measure the overhead of a small log call. |
| 20 | func 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 | |
| 41 | func BenchmarkSpanLoggerWithRealLogger(b *testing.B) { |
| 42 | testCases := map[string]bool{ |
nothing calls this directly
no test coverage detected