-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
normalize: Improve ToCRLF/StringToCRLF performance
The ToCRLF/StringToCRLF functions are not very performance critical, but we call it for each mail, and the current implementation is very inefficient (mainly because it goes one byte at a time). This patch replaces it with a better implementation that goes line by line. The new implementation of ToCRLF is ~40% faster, and StringToCRLF is ~60% faster. ``` $ benchstat old.txt new.txt goos: linux goarch: amd64 pkg: blitiri.com.ar/go/chasquid/internal/normalize cpu: 13th Gen Intel(R) Core(TM) i9-13900T │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ ToCRLF-32 162.96µ ± 6% 95.42µ ± 12% -41.44% (p=0.000 n=10) StringToCRLF-32 190.70µ ± 14% 76.51µ ± 6% -59.88% (p=0.000 n=10) geomean 176.3µ 85.44µ -51.53% ```
- Loading branch information
Showing
2 changed files
with
95 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters