Skip to content

M4 max shows unexpected results for nightly format_into() vs itoa crate #1

@sammysheep

Description

@sammysheep

@GuillaumeGomez This is feedback for rust-lang/rust#142098.

On an Apple M4 Max with rustc 1.90.0-nightly (855e0fe46 2025-07-11) the results look like this:

test bench::all_digits::itoa ... bench:          51.07 ns/iter (+/- 1.89)
test bench::all_digits::std1 ... bench:         436.27 ns/iter (+/- 30.34)
test bench::all_digits::std2 ... bench:         582.99 ns/iter (+/- 49.70)
test bench::all_digits::std3 ... bench:          64.49 ns/iter (+/- 3.20)
test bench::first_999::itoa  ... bench:         500.48 ns/iter (+/- 25.55)
test bench::first_999::std1  ... bench:      15,732.48 ns/iter (+/- 1,030.35)
test bench::first_999::std2  ... bench:      22,634.60 ns/iter (+/- 1,111.68)
test bench::first_999::std3  ... bench:       1,346.81 ns/iter (+/- 19.22)
test bench::first_9::itoa    ... bench:           2.23 ns/iter (+/- 0.02)
test bench::first_9::std1    ... bench:         149.36 ns/iter (+/- 5.87)
test bench::first_9::std2    ... bench:         221.03 ns/iter (+/- 8.88)
test bench::first_9::std3    ... bench:          11.39 ns/iter (+/- 0.32)
  • std1 is to_string()
  • std2 is format!()
  • std3 is NumBuffer (nightly feature)
  • itoa is David Tolnay's crate

When I bench things on real world code I don't see quite such a difference between itoa and the nightly feature (std3), but I wanted to report it in case it is not an artifact of the test.

Thanks so much for doing this work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions