tr: add codspeed benchmark#12189
Open
parasol-aser wants to merge 1 commit intouutils:mainfrom
Open
Conversation
|
GNU testsuite comparison: |
sylvestre
reviewed
May 7, 2026
|
|
||
| `tr` performance is critical for large data processing pipelines. The implementation uses lookup tables for O(1) character operations. | ||
|
|
||
| ## CodSpeed (CI) |
sylvestre
reviewed
May 7, 2026
| /// Exercises the AVX2 ASCII-range fast path on x86_64 hosts that | ||
| /// support it, and the scalar range fallback on other targets. | ||
| #[cfg(unix)] | ||
| #[divan::bench(args = [1, 16, 64])] |
Contributor
There was a problem hiding this comment.
Please test with only one value
Author
There was a problem hiding this comment.
Done in 190a973 — collapsed to a single 16 MB size (SIZE_MB const) across all four benches.
Adds a divan-based benchmark suite under src/uu/tr/benches/ that codspeed can build and run, and registers uu_tr in the benchmarks workflow matrix. Each bench redirects fd 0 to a prepared file and fd 1 to /dev/null around uumain since tr only reads stdin. Covers the AVX2 ASCII-range fast path, single-char replace, multi-char table translation, and ASCII range delete, at 1/16/64 MB.
f99615e to
190a973
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a divan-based benchmark suite at
src/uu/tr/benches/tr_bench.rs, registered in.github/workflows/benchmarks.ymlso CodSpeed tracks it on every PR.tronly reads stdin, so each bench redirects fd 0 to a prepared file (and fd 1 to/dev/null) arounduumain, mirroring the existingsrc/uu/tee/benches/tee_bench.rspattern withrustix.The suite covers four cases at 1 / 16 / 64 MB inputs:
tr_ascii_range_lower_to_upper—tr a-z A-Z(range translation)tr_single_char_replace—tr a b(single-byte SIMD path)tr_multi_char_translate—tr aeiou AEIOU(table-lookup path)tr_delete_ascii_range—tr -d a-z(deletion path)Why
Requested by @sylvestre in #12118 to provide regression coverage for the
trtranslation paths and the upcoming AVX2 ASCII-range fast path landing in that PR.Local invocation
Notes
#[cfg(unix)]because the rustix stdin/stdout redirection is unix-only; on other targets the bench compiles to an emptydivan::main().benches/,Cargo.tomldev-deps, and the workflow matrix.