Skip to content

numfmt & others: Dedup some code #11645

Merged
cakebaker merged 9 commits intouutils:mainfrom
sylvestre:numfmt-3
Apr 5, 2026
Merged

numfmt & others: Dedup some code #11645
cakebaker merged 9 commits intouutils:mainfrom
sylvestre:numfmt-3

Conversation

@sylvestre
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

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/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 5, 2026

Merging this PR will degrade performance by 4.82%

❌ 8 regressed benchmarks
✅ 301 untouched benchmarks
⏩ 46 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation numfmt_to_iec[10000] 35.7 ms 37.5 ms -4.81%
Simulation numfmt_large_numbers_si[10000] 38.4 ms 40.2 ms -4.43%
Simulation numfmt_to_si_precision[10000] 37 ms 38.8 ms -4.63%
Simulation numfmt_round_modes[("up", 10000)] 36.3 ms 38.1 ms -4.71%
Simulation numfmt_round_modes[("down", 10000)] 36.2 ms 38 ms -4.74%
Simulation numfmt_round_modes[("towards-zero", 10000)] 36.3 ms 38.1 ms -4.73%
Simulation numfmt_padding[(10000, 50)] 38.8 ms 40.6 ms -4.48%
Simulation numfmt_to_si[10000] 35.5 ms 37.3 ms -4.82%

Comparing sylvestre:numfmt-3 (96be503) with main (c5cff82)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use std::fmt;
use uucore::parser::parse_size::{IEC_BASES as IEC_BASES_U128, SI_BASES as SI_BASES_U128};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the reason for the renames?

Comment on lines +46 to +62
/// Index of this suffix in the base arrays, minus one.
/// `K` is 0, `M` is 1, ..., `Q` is 9. The associated base is
/// `BASES[self.index() + 1]`.
pub fn index(self) -> usize {
match self {
Self::K => 0,
Self::M => 1,
Self::G => 2,
Self::T => 3,
Self::P => 4,
Self::E => 5,
Self::Z => 6,
Self::Y => 7,
Self::R => 8,
Self::Q => 9,
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This feels error prone, though currently I don't see a better solution :|

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

GNU testsuite comparison:

GNU test failed: tests/timeout/timeout-group. tests/timeout/timeout-group is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/seq/seq-epipe is now being skipped but was previously passing.
Congrats! The gnu test tests/printf/printf-surprise is now passing!

@cakebaker cakebaker merged commit 12cdba2 into uutils:main Apr 5, 2026
167 of 169 checks passed
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