Skip to content

Commit

Permalink
Re-run benchmarks and add % over zap measurement (uber-go#720)
Browse files Browse the repository at this point in the history
Benchmarks were last run 2y ago, so it's time to see how the
lay of the land has changed.

Just baseline wise it appears that my laptop is about 50%
faster than the hardware that the initial benchmarks were
ran on, but it doesn't really change the relative difference
in the loggers.

Zerolog appears to have closed the distance quite a bit,
while others are still an order of magnitude slower than
zap.

* Drop lion; re-run bench

* Update the x/lint location

* Re-up with cleared glide cache

* Include relative % using zap as baseline

* Update internal/readme/readme.go
  • Loading branch information
glibsm authored and prashantv committed Jun 19, 2019
1 parent 8a2ee56 commit 853ac18
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 139 deletions.
5 changes: 3 additions & 2 deletions .readme.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ pinned in zap's [glide.lock][] file. [↩](#anchor-versions)

[doc-img]: https://godoc.org/go.uber.org/zap?status.svg
[doc]: https://godoc.org/go.uber.org/zap
[ci-img]: https://travis-ci.org/uber-go/zap.svg?branch=master
[ci]: https://travis-ci.org/uber-go/zap
[ci-img]: https://travis-ci.com/uber-go/zap.svg?branch=master
[ci]: https://travis-ci.com/uber-go/zap
[cov-img]: https://codecov.io/gh/uber-go/zap/branch/master/graph/badge.svg
[cov]: https://codecov.io/gh/uber-go/zap
[benchmarking suite]: https://github.com/uber-go/zap/tree/master/benchmarks
[glide.lock]: https://github.com/uber-go/zap/blob/master/glide.lock

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies:
go install ./vendor/github.com/mattn/goveralls
ifdef SHOULD_LINT
@echo "Installing golint..."
go install ./vendor/github.com/golang/lint/golint
go install ./vendor/golang.org/x/lint/golint
else
@echo "Not installing golint, since we don't expect to lint on" $(GO_VERSION)
endif
Expand Down
60 changes: 29 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,43 +64,40 @@ id="anchor-versions">[1](#footnote-versions)</sup>

Log a message and 10 fields:

| Package | Time | Objects Allocated |
| :--- | :---: | :---: |
| :zap: zap | 3131 ns/op | 5 allocs/op |
| :zap: zap (sugared) | 4173 ns/op | 21 allocs/op |
| zerolog | 16154 ns/op | 90 allocs/op |
| lion | 16341 ns/op | 111 allocs/op |
| go-kit | 17049 ns/op | 126 allocs/op |
| logrus | 23662 ns/op | 142 allocs/op |
| log15 | 36351 ns/op | 149 allocs/op |
| apex/log | 42530 ns/op | 126 allocs/op |
| Package | Time | Time % to zap | Objects Allocated |
| :------ | :--: | :-----------: | :---------------: |
| :zap: zap | 862 ns/op | +0% | 5 allocs/op
| :zap: zap (sugared) | 1250 ns/op | +45% | 11 allocs/op
| zerolog | 4021 ns/op | +366% | 76 allocs/op
| go-kit | 4542 ns/op | +427% | 105 allocs/op
| apex/log | 26785 ns/op | +3007% | 115 allocs/op
| logrus | 29501 ns/op | +3322% | 125 allocs/op
| log15 | 29906 ns/op | +3369% | 122 allocs/op

Log a message with a logger that already has 10 fields of context:

| Package | Time | Objects Allocated |
| :--- | :---: | :---: |
| :zap: zap | 380 ns/op | 0 allocs/op |
| :zap: zap (sugared) | 564 ns/op | 2 allocs/op |
| zerolog | 321 ns/op | 0 allocs/op |
| lion | 7092 ns/op | 39 allocs/op |
| go-kit | 20226 ns/op | 115 allocs/op |
| logrus | 22312 ns/op | 130 allocs/op |
| log15 | 28788 ns/op | 79 allocs/op |
| apex/log | 42063 ns/op | 115 allocs/op |
| Package | Time | Time % to zap | Objects Allocated |
| :------ | :--: | :-----------: | :---------------: |
| :zap: zap | 126 ns/op | +0% | 0 allocs/op
| :zap: zap (sugared) | 187 ns/op | +48% | 2 allocs/op
| zerolog | 88 ns/op | -30% | 0 allocs/op
| go-kit | 5087 ns/op | +3937% | 103 allocs/op
| log15 | 18548 ns/op | +14621% | 73 allocs/op
| apex/log | 26012 ns/op | +20544% | 104 allocs/op
| logrus | 27236 ns/op | +21516% | 113 allocs/op

Log a static string, without any context or `printf`-style templating:

| Package | Time | Objects Allocated |
| :--- | :---: | :---: |
| :zap: zap | 361 ns/op | 0 allocs/op |
| :zap: zap (sugared) | 534 ns/op | 2 allocs/op |
| zerolog | 323 ns/op | 0 allocs/op |
| standard library | 575 ns/op | 2 allocs/op |
| go-kit | 922 ns/op | 13 allocs/op |
| lion | 1413 ns/op | 10 allocs/op |
| logrus | 2291 ns/op | 27 allocs/op |
| apex/log | 3690 ns/op | 11 allocs/op |
| log15 | 5954 ns/op | 26 allocs/op |
| Package | Time | Time % to zap | Objects Allocated |
| :------ | :--: | :-----------: | :---------------: |
| :zap: zap | 118 ns/op | +0% | 0 allocs/op
| :zap: zap (sugared) | 191 ns/op | +62% | 2 allocs/op
| zerolog | 93 ns/op | -21% | 0 allocs/op
| go-kit | 280 ns/op | +137% | 11 allocs/op
| standard library | 499 ns/op | +323% | 2 allocs/op
| apex/log | 1990 ns/op | +1586% | 10 allocs/op
| logrus | 3129 ns/op | +2552% | 24 allocs/op
| log15 | 3887 ns/op | +3194% | 23 allocs/op

## Development Status: Stable

Expand Down Expand Up @@ -134,3 +131,4 @@ pinned in zap's [glide.lock][] file. [↩](#anchor-versions)
[cov]: https://codecov.io/gh/uber-go/zap
[benchmarking suite]: https://github.com/uber-go/zap/tree/master/benchmarks
[glide.lock]: https://github.com/uber-go/zap/blob/master/glide.lock

31 changes: 0 additions & 31 deletions benchmarks/lion_test.go

This file was deleted.

27 changes: 0 additions & 27 deletions benchmarks/scenario_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,6 @@ func BenchmarkWithoutFields(b *testing.B) {
}
})
})
b.Run("go.pedge.io/lion", func(b *testing.B) {
logger := newLion()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.Printf(getMessage(0))
}
})
})
b.Run("stdlib.Println", func(b *testing.B) {
logger := log.New(ioutil.Discard, "", log.LstdFlags)
b.ResetTimer()
Expand Down Expand Up @@ -462,15 +453,6 @@ func BenchmarkAccumulatedContext(b *testing.B) {
}
})
})
b.Run("go.pedge.io/lion", func(b *testing.B) {
logger := newLion().WithFields(fakeLogrusFields())
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.Infof(getMessage(0))
}
})
})
b.Run("rs/zerolog", func(b *testing.B) {
logger := fakeZerologContext(newZerolog().With()).Logger()
b.ResetTimer()
Expand Down Expand Up @@ -582,15 +564,6 @@ func BenchmarkAddingFields(b *testing.B) {
}
})
})
b.Run("go.pedge.io/lion", func(b *testing.B) {
logger := newLion()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.WithFields(fakeLogrusFields()).Infof(getMessage(0))
}
})
})
b.Run("rs/zerolog", func(b *testing.B) {
logger := newZerolog()
b.ResetTimer()
Expand Down
62 changes: 30 additions & 32 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ testImport:
- package: github.com/mattn/goveralls
- package: github.com/pborman/uuid
- package: github.com/pkg/errors
- package: go.pedge.io/lion
- package: github.com/rs/zerolog
- package: golang.org/x/tools
subpackages:
- cover
- package: github.com/golang/lint
- package: golang.org/x/lint
subpackages:
- golint
- package: github.com/axw/gocov
Expand Down
Loading

0 comments on commit 853ac18

Please sign in to comment.