Skip to content

Comments

perf: use bit shifts for power-of-two formatting#565

Merged
prestwich merged 2 commits intorecmo:mainfrom
DaniPopes:dani/fmt-pow2-fast-paths
Feb 12, 2026
Merged

perf: use bit shifts for power-of-two formatting#565
prestwich merged 2 commits intorecmo:mainfrom
DaniPopes:dani/fmt-pow2-fast-paths

Conversation

@DaniPopes
Copy link
Contributor

No description provided.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 7, 2026

Merging this PR will improve performance by ×7.7

⚡ 12 improved benchmarks
✅ 374 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
fmt/hex/256 8 ms 4.5 ms +77.12%
fmt/hex/384 11.2 ms 6.3 ms +76.96%
fmt/hex/192 6.4 ms 3.6 ms +80.5%
fmt/hex/4096 4,519.8 µs 584.9 µs ×7.7
fmt/octal/256 8.6 ms 7.3 ms +18.66%
fmt/hex/512 14.4 ms 8.1 ms +77.43%
fmt/octal/512 15.8 ms 13.7 ms +15.13%
fmt/octal/4096 4.4 ms 1.3 ms ×3.5
fmt/binary/4096 5.3 ms 2.3 ms ×2.3
most_significant_bits/4096/4096 28.9 µs 26.1 µs +10.88%
to/f32/4096 29.1 µs 26.2 µs +11.12%
to/f64/4096 29.3 µs 26.4 µs +11.17%

Comparing DaniPopes:dani/fmt-pow2-fast-paths (04e7742) with main (fa46a21)

Open in CodSpeed

@DaniPopes DaniPopes force-pushed the dani/fmt-pow2-fast-paths branch 3 times, most recently from edd7b13 to b72377b Compare February 12, 2026 00:04
@DaniPopes DaniPopes force-pushed the dani/fmt-pow2-fast-paths branch from b72377b to 0951194 Compare February 12, 2026 00:06
@prestwich prestwich requested a review from gakonst February 12, 2026 00:06
@DaniPopes DaniPopes force-pushed the dani/fmt-pow2-fast-paths branch from 0951194 to d7e0bd7 Compare February 12, 2026 00:08
}
}

impl_fmt!(fmt::Display; base::Decimal, "");
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is now the only invocation of this macro. should it still be a macro?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks nicer :(

Copy link
Collaborator

Choose a reason for hiding this comment

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

lol cool

@DaniPopes DaniPopes requested a review from prestwich February 12, 2026 00:27
@prestwich prestwich merged commit a5d8e2c into recmo:main Feb 12, 2026
19 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.

3 participants