(b *testing.B)
| 260 | } |
| 261 | |
| 262 | func Benchmark100Fields(b *testing.B) { |
| 263 | const batchSize = 50 |
| 264 | logger := New(zapcore.NewCore( |
| 265 | zapcore.NewJSONEncoder(NewProductionConfig().EncoderConfig), |
| 266 | &ztest.Discarder{}, |
| 267 | DebugLevel, |
| 268 | )) |
| 269 | |
| 270 | // Don't include allocating these helper slices in the benchmark. Since |
| 271 | // access to them isn't synchronized, we can't run the benchmark in |
| 272 | // parallel. |
| 273 | first := make([]Field, batchSize) |
| 274 | second := make([]Field, batchSize) |
| 275 | b.ResetTimer() |
| 276 | |
| 277 | for i := 0; i < b.N; i++ { |
| 278 | for i := 0; i < batchSize; i++ { |
| 279 | // We're duplicating keys, but that doesn't affect performance. |
| 280 | first[i] = Int("foo", i) |
| 281 | second[i] = Int("foo", i+batchSize) |
| 282 | } |
| 283 | logger.With(first...).Info("Child loggers with lots of context.", second...) |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | func BenchmarkAny(b *testing.B) { |
| 288 | key := "some-long-string-longer-than-16" |
nothing calls this directly
no test coverage detected