aboutsummaryrefslogtreecommitdiff
path: root/lib/mlog/benchmark_test.go
AgeCommit message (Collapse)Author
2026-01-15all: convert license and copyright to use SPDX identifiersShulhan
With help of spdxconv tool [1], we able to bulk update all files license and copyright format to comply with SPDX formats. [1] https://kilabit.info/project/spdxconv/
2024-03-05all: comply with linter recommendations #2Shulhan
HTTP request now implicitly create request with context. Any false positive related to not closing HTTP response body has been annotated with "nolint:bodyclose". In the example code, use consistent "// Output:" comment format, by prefixing with single space. Any comment on code now also prefixing with single space. An error returned without variables now use [errors.New] instead of [fmt.Errorf]. Any error returned using [fmt.Errorf] now wrapped using "%w" instead of "%s". Also, replace error checking using [errors.Is] or [errors.As], instead of using equal/not-equal operator. Any statement like "x = x OP y" now replaced with "x OP= y". Also, swap statement is simplified using "x, y = y, x". Any switch statement with single case now replaced with if-condition. Any call to defer on function or program that call [os.Exit], now replaced by calling the deferred function directly. Any if-else condition now replaced with switch statement, if possible.
2022-06-27lib/mlog: minimize allocation when generating logShulhan
Instead of using two bytes.Buffer pool, use one; and add space after time and prefix by writing to buffer directly instead of allocating new arguments to Fprintf. Benchmark result, name old time/op new time/op delta MultiLogger-8 3.97µs ± 3% 3.68µs ± 2% -7.43% (p=0.008 n=5+5) name old alloc/op new alloc/op delta MultiLogger-8 510B ± 1% 300B ± 1% -41.13% (p=0.008 n=5+5) name old allocs/op new allocs/op delta MultiLogger-8 10.4 ± 6% 3.4 ±18% -67.31% (p=0.008 n=5+5)