Add benchmark for context appending

This commit is contained in:
Olivier Poitrey 2017-08-29 23:10:40 -07:00
parent e26050b2a3
commit d76a89fffc
1 changed files with 12 additions and 0 deletions

View File

@ -57,6 +57,18 @@ func BenchmarkContextFields(b *testing.B) {
}) })
} }
func BenchmarkContextAppend(b *testing.B) {
logger := New(ioutil.Discard).With().
Str("foo", "bar").
Logger()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.With().Str("bar", "baz")
}
})
}
func BenchmarkLogFields(b *testing.B) { func BenchmarkLogFields(b *testing.B) {
logger := New(ioutil.Discard) logger := New(ioutil.Discard)
b.ResetTimer() b.ResetTimer()