This is a Rust port of {fmt}'s dtoa-benchmark by Victor Zverovich, which is a fork of Milo Yip's dtoa-benchmark.
This benchmark evaluates the performance of conversion from double precision IEEE-754 floating point (f64) to ASCII string.
Input data: The benchmark generates f64 bit patterns using a simplistic pseudorandom number generator, bitcasting from 64-bit integer to f64 and discarding +/-inf and NaN. It truncates each value to a limited precision ranging from 1 to 17 decimal digits in the significand, producing an equal number of values of each precision.
Measurement: For each dtoa library, for each precision group, we perform multiple passes over the input data and take the duration of the fastest pass. Then these fastest durations are averaged across the 17 f64 precision groups to produce the table below.
Build and run the benchmark yourself using cargo run --release.
The following results are measured on a 2025 AMD Ryzen Threadripper 9975WX and 2024 Apple M4 Max, each using Rust 1.92.0:
| Library | 9975WX (x86_64) | M4 Max (aarch64) | ||
|---|---|---|---|---|
| Time (ns) | Speedup | Time (ns) | Speedup | |
| libcore | 67.7 | 1.00× | 61.1 | 1.00× |
| dtoa | 41.8 | 1.62× | 43.7 | 1.40× |
| ryu | 31.2 | 2.17× | 26.4 | 2.31× |
| lexical | 24.0 | 2.82× | 21.2 | 2.88× |
| teju | 23.0 | 2.94× | 19.0 | 3.22× |
| zmij | 11.0 | 6.15× | 7.7 | 7.93× |
