Skip to content

Benchmark Rust f64-to-string conversion libraries

License

Notifications You must be signed in to change notification settings

dtolnay/dtoa-benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dtoa Benchmark

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.

Procedure

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.

Results

The following results are measured on a 2025 AMD Ryzen Threadripper 9975WX and 2024 Apple M4 Max, each using Rust 1.92.0:

Library9975WX (x86_64)M4 Max (aarch64)
Time (ns)SpeedupTime (ns)Speedup
libcore67.71.00×61.11.00×
dtoa41.81.62×43.71.40×
ryu31.22.17×26.42.31×
lexical24.02.82×21.22.88×
teju23.02.94×19.03.22×
zmij11.06.15×7.77.93×

performance

About

Benchmark Rust f64-to-string conversion libraries

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project