Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove call to isatty from the hot path.
The result from isatty is immutable during the run of the program and is triggering a heavy system call that significantly slow down answering request. $ benchstat before.txt after.txt goos: darwin goarch: amd64 pkg: github.com/gin-contrib/logger cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz │ before.txt │ after.txt │ │ sec/op │ sec/op vs base │ Logger 2.924µ ± 2% 1.617µ ± 12% -44.70% (p=0.000 n=10) Logger-2 1649.0n ± 2% 766.1n ± 1% -53.54% (p=0.000 n=10) Logger-4 1009.5n ± 11% 496.6n ± 12% -50.80% (p=0.000 n=10) Logger-8 853.4n ± 3% 396.4n ± 12% -53.56% (p=0.000 n=10) geomean 1.428µ 702.7n -50.78%
- Loading branch information