Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
funcr: optimize WithValues/WithName/WithContext
All of these functions indirectly copied the entire Options struct because it gets stored by value in the Formatter and thus fnlogger. The struct is read-only, therefore sharing a single copy by pointer via different logger instances is possible. Performance for the context value benchmark gets better: name old time/op new time/op delta NewContext1Percent-36 32.4µs ± 5% 31.8µs ± 3% ~ (p=0.421 n=5+5) NewContext100PercentDisabled-36 51.0µs ± 4% 49.4µs ± 2% ~ (p=0.095 n=5+5) NewContext100Percent-36 572µs ± 4% 534µs ± 2% -6.77% (p=0.008 n=5+5) name old alloc/op new alloc/op delta NewContext1Percent-36 11.3kB ± 0% 11.2kB ± 0% -0.71% (p=0.008 n=5+5) NewContext100PercentDisabled-36 19.2kB ± 0% 19.2kB ± 0% ~ (all equal) NewContext100Percent-36 178kB ± 0% 170kB ± 0% -4.48% (p=0.008 n=5+5) name old allocs/op new allocs/op delta NewContext1Percent-36 220 ± 0% 220 ± 0% ~ (all equal) NewContext100PercentDisabled-36 300 ± 0% 300 ± 0% ~ (all equal) NewContext100Percent-36 2.20k ± 0% 2.20k ± 0% ~ (all equal)
- Loading branch information