Skip to content

ptx: add benchmark#13480

Open
Aisha630 wants to merge 5 commits into
uutils:mainfrom
Aisha630:ptx-add-benchmark
Open

ptx: add benchmark#13480
Aisha630 wants to merge 5 commits into
uutils:mainfrom
Aisha630:ptx-add-benchmark

Conversation

@Aisha630

@Aisha630 Aisha630 commented Jul 20, 2026

Copy link
Copy Markdown

ptx: add benchmark

Summary

I'm adding Divan benchmarks for ptx.

This is a benchmark-only change. No utility code is touched.

Why

ptx had no benchmark. Its cost is dominated by converting keyword byte offsets to character offsets while building the output, which grows with the line length. So the benchmarks hold the total input size roughly constant and vary the line length, which is what surfaces that behavior. It also gives us a baseline to measure the offset-conversion optimization I'm proposing separately.

Benchmarks

Bench Args Covers
ptx_short_lines 100_000 lines many short lines
ptx_long_lines 100 lines fixed ~1 MiB spread over fewer, longer lines
ptx_input_references_short_lines 100_000 lines -r , short lines
ptx_input_references_long_lines 100 lines -r on fewer, longer lines

I followed the guidelines in the performance.md file and drew inspiration from the tr, nl, cat benchmarks that were already set up.

Comment thread src/uu/ptx/benches/ptx_bench.rs Outdated
Comment thread src/uu/ptx/benches/ptx_bench.rs Outdated
@oech3

oech3 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Can we use file for benchmark and use std instead of rustix?

@Aisha630

Copy link
Copy Markdown
Author

Can we use file for benchmark and use std instead of rustix?

Done. Removed the extra dependencies as well. I did the redirection earlier because running the benchmark locally was flooding the terminal. But I suppose that's a non-issue.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/seq/seq-epipe is now passing!

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.

3 participants