Skip to content

Conversation

@sylvestre
Copy link
Contributor

Results:

$ dd if=/dev/zero bs=1M count=10 | tr '\0' 'x' > 10mb_input
$ hyperfine --export-markdown tr.md --warmup 3 \
    '/usr/bin/tr a b < 10mb_input > /dev/null' \
    './target/release/tr a b < 10mb_input > /dev/null' \
    './target/release/tr.previous a b < 10mb_input > /dev/null'
Benchmark 1: /usr/bin/tr a b < 10mb_input > /dev/null
  Time (mean ± σ):       6.5 ms ±   0.7 ms    [User: 4.1 ms, System: 2.4 ms]
  Range (min … max):     5.1 ms …  10.3 ms    520 runs

Benchmark 2: ./target/release/tr a b < 10mb_input > /dev/null
  Time (mean ± σ):      10.7 ms ±   0.8 ms    [User: 7.9 ms, System: 2.7 ms]
  Range (min … max):     9.7 ms …  15.3 ms    271 runs

Benchmark 3: ./target/release/tr.previous a b < 10mb_input > /dev/null
  Time (mean ± σ):      61.2 ms ±   2.2 ms    [User: 58.5 ms, System: 2.5 ms]
  Range (min … max):    58.4 ms …  66.9 ms    47 runs

Summary
  /usr/bin/tr a b < 10mb_input > /dev/null ran
    1.64 ± 0.23 times faster than ./target/release/tr a b < 10mb_input > /dev/null
    9.39 ± 1.12 times faster than ./target/release/tr.previous a b < 10mb_input > /dev/null

Not as fast as GNU but much better than the previous implementation

Command Mean [ms] Min [ms] Max [ms] Relative
/usr/bin/tr a b < 10mb_input > /dev/null 6.5 ± 0.7 5.1 10.3 1.00
./target/release/tr a b < 10mb_input > /dev/null 10.7 ± 0.8 9.7 15.3 1.64 ± 0.23
./target/release/tr.previous a b < 10mb_input > /dev/null 61.2 ± 2.2 58.4 66.9 9.39 ± 1.12

@github-actions
Copy link

github-actions bot commented Aug 6, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Aug 6, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

Copy link
Collaborator

@drinkcat drinkcat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The u8 array scared me at first, but... this is broken anyway ,-)

echo "Héállo" | env tr -d 'é' | hexdump -C
00000000  48 a1 6c 6c 6f 0a                                 |H.llo.|

@github-actions
Copy link

github-actions bot commented Aug 8, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/stdbuf (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Aug 8, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/tee (passes in this run but fails in the 'main' branch)

@drinkcat
Copy link
Collaborator

drinkcat commented Aug 9, 2025

6x improvement is great start! ,-P Thanks!

@drinkcat drinkcat merged commit d535824 into uutils:main Aug 9, 2025
130 of 131 checks passed
@sylvestre sylvestre deleted the tr-perf branch August 20, 2025 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants