Skip to content

Commit

Permalink
README: add logger type doc and updated benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
rezkam authored Jul 24, 2020
1 parent baaac8c commit 432d9e7
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions README.md
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
```

0 comments on commit 432d9e7

Please sign in to comment.