This directory is its own module, with a replace pointing at the checkout one
level up, so it always measures the working tree.
$ cd _benchmarks
$ go test -run xxx -bench . -benchmem -count=3Each operation writes three log lines (error, warning, info) to a nop output,
except BenchmarkGologPrintFile, which writes them to a real file so that the
syscalls count too.
| test | ns/op (small is better) | B/op (small is better) | allocs/op (small is better) |
|---|---|---|---|
| BenchmarkGologPrint | 923 ns/op | 154 B/op | 5 allocs/op |
| BenchmarkGologPrintJSON | 2805 ns/op | 148 B/op | 5 allocs/op |
| BenchmarkGologPrintFile | 9067 ns/op | 139 B/op | 5 allocs/op |
| BenchmarkLogrusPrint | 7243 ns/op | 1742 B/op | 54 allocs/op |
| BenchmarkStdPrint | 1130 ns/op | 72 B/op | 5 allocs/op |
BenchmarkStdPrint is the standard library's log, which has no levels, no
fields and no formatter to run: it is the floor, not a competitor. The
benchmarks are built in CI but not run there; timings from a shared runner are
noise.
Feel free to send a PR of your own logger benchmark to put it here!
