hibiken / asynq

Simple, reliable, and efficient distributed task queue in Go
MIT License
10.03k stars 716 forks source link

Minor optimization by avoiding fmt.Sprintf on hot path #962

Closed pior closed 1 week ago

pior commented 1 week ago

Context

While fmt.Sprintf is handy, and usually fast enough for most use-cases, we should probably avoid using it for string concatenation on the hot path.

Micro-benchmark:

BenchmarkBase/sprintf-8             19425255            61.85 ns/op       32 B/op          2 allocs/op
BenchmarkBase/concat-8              84949484            14.20 ns/op        0 B/op          0 allocs/op

Changes

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 66.31%. Comparing base (4f00f52) to head (2d6d6f4). Report is 4 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #962 +/- ## ========================================== - Coverage 67.13% 66.31% -0.83% ========================================== Files 29 29 Lines 4300 5729 +1429 ========================================== + Hits 2887 3799 +912 - Misses 1135 1651 +516 - Partials 278 279 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.