-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
README: add logger type doc and updated benchmarks
- Loading branch information
Showing
1 changed file
with
19 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
# Benchmark for Logging With Zap | ||
|
||
## Logger Types | ||
### Discarded Logger | ||
Sends all the writes to ioutil.Discard | ||
### Sampled Logger | ||
Creates a zap core that samples incoming N (here is 10) entries, with a given level and message | ||
each tick. If more Entries with the same level and message are seen during the same interval, every Mth message is logged and the rest are dropped. | ||
### Writer Logger | ||
Sneds all the writes to a writer (stderr) without sampling. | ||
### WriterSampler | ||
Writer Logger with a sampler. | ||
|
||
## Benchmark Results | ||
on my MacBook Pro | ||
``` | ||
➜ BenchmarkZapLoggers git:(master) ✗ go test -bench=. | ||
goos: darwin | ||
goarch: amd64 | ||
pkg: github.com/rezakamalifard/BenchmarkZapLoggers | ||
BenchmarkSugarLogger-4 793906 1260 ns/op 512 B/op 1 allocs/op | ||
BenchmarkStructuredLogger-4 1262098 950 ns/op 256 B/op 1 allocs/op | ||
PASS | ||
ok github.com/rezakamalifard/BenchmarkZapLoggers 3.575s | ||
BenchmarkDiscardedSugarLogger 817209 1292 ns/op 512 B/op 1 allocs/op | ||
BenchmarkDiscardedStructuredLogger 1000000 1010 ns/op 256 B/op 1 allocs/op | ||
BenchmarkSampledSugarLogger 3972433 277 ns/op 51 B/op 0 allocs/op | ||
BenchmarkSampledStructuredLogger 3486465 356 ns/op 256 B/op 1 allocs/op | ||
BenchmarkWriterSugarLogger 85296 14986 ns/op 760 B/op 4 allocs/op | ||
BenchmarkWriterStructuredLogger 57351 17587 ns/op 504 B/op 4 allocs/op | ||
BenchmarkWriterSamplerSugarLogger 3176926 563 ns/op 7 B/op 0 allocs/op | ||
BenchmarkWriterSamplerStructuredLogger 2051127 610 ns/op 258 B/op 1 allocs/op | ||
``` |