Skip to content

itoa used correctly is faster than numtoa used correctly #5

@dtolnay

Description

@dtolnay

#4 (comment)

Based on the benchmark code in #4 but writing to Vec<u8>, itoa is about 10% faster.

let mut null = Vec::new();

for number in 0..100_000_000u64 {
    null.clear();
    /* write */
}
numtoa: 995 ms
itoa: 866 ms
std: 2803 ms

This is an important use case because it is a good model of what serde_json::to_string is doing, for example.

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