(b *testing.B)
| 17 | ) |
| 18 | |
| 19 | func 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 | |
| 35 | func TestLazySprintf(t *testing.T) { |
| 36 | tests := map[string]struct { |
nothing calls this directly
no test coverage detected