How Dec compares with rust_decimal,
fastnum and native f64 across the operations a
trading system runs on a hot path. Every number is nanoseconds for one
operation, taken as the median over 1,024 values.
cpu Intel(R) Core(TM) Ultra 9 285Harch x86_64rustc rustc 1.98.0 (88d9e12ae 2026-08-18)commit 2265b09measured 2026-09-04 10:59 UTC
Per operation
Each chart is scaled to its own slowest bar, so a chart shows who wins that
operation and by how much — not how operations compare with each other.
f64 is drawn in grey because it is the inexact reference, not a
decimal competing on correctness.
f64 — inexact referenceDecrust_decimalfastnum
cmp
Compare two values
f64
0.10 ns
Dec
0.31 ns
rust_decimal
3.34 ns
fastnum
4.29 ns
add
Add into an accumulator
f64
0.39 ns
Dec
0.85 ns
rust_decimal
1.76 ns
fastnum
8.01 ns
mul
Multiply price by size
f64
0.16 ns
Dec
3.33 ns
rust_decimal
6.13 ns
fastnum
4.39 ns
div
Divide price by size
f64
0.77 ns
Dec
16.9 ns
rust_decimal
26.6 ns
fastnum
77.4 ns
round_dp
Round to 2 decimal places
f64
0.91 ns
Dec
4.18 ns
rust_decimal
13.3 ns
fastnum
7.47 ns
round_to_step
Round to a 0.01 step
f64
1.04 ns
Dec
3.33 ns
rust_decimal
24.1 ns
fastnum
19.7 ns
floor
Floor to an integer
f64
1.02 ns
Dec
3.52 ns
rust_decimal
6.68 ns
fastnum
9.86 ns
ceil
Ceiling to an integer
f64
1.01 ns
Dec
3.98 ns
rust_decimal
7.68 ns
fastnum
14.4 ns
to_f64
Convert to f64
f64
not applicable
Dec
1.35 ns
rust_decimal
17.0 ns
fastnum
1.88 ns
from_f64
Convert from f64
f64
not applicable
Dec
8.93 ns
rust_decimal
80.9 ns
fastnum
75.8 ns
parse
Parse from a string
f64
6.49 ns
Dec
7.30 ns
rust_decimal
10.8 ns
fastnum
15.4 ns
format
Format to a string
f64
56.5 ns
Dec
23.5 ns
rust_decimal
29.8 ns
fastnum
45.2 ns
collect
Parse a batch into a fresh Vec
f64
7.18 ns
Dec
7.91 ns
rust_decimal
10.4 ns
fastnum
9.54 ns
clone
Allocate and copy a Vec
f64
0.06 ns
Dec
0.09 ns
rust_decimal
0.11 ns
fastnum
0.51 ns
Parsing by digit width
The parser accumulates in a u64 and promotes to u128 once a mantissa passes 19 digits, so the cost of that promotion is visible as the curve steepens past the boundary.
Formatting by digit width
Rendering walks the digits it has, so the curve is the cost of the digits themselves rather than of any one value.
Summary
The same numbers as one table.
operation
f64
Dec
rust_decimal
fastnum
cmp
0.10
0.31
3.34
4.29
add
0.39
0.85
1.76
8.01
mul
0.16
3.33
6.13
4.39
div
0.77
16.93
26.58
77.45
round_dp
0.91
4.18
13.35
7.47
round_to_step
1.04
3.33
24.06
19.73
floor
1.02
3.52
6.68
9.86
ceil
1.01
3.98
7.68
14.43
to_f64
—
1.35
17.01
1.88
from_f64
—
8.93
80.90
75.78
parse
6.49
7.30
10.81
15.39
format
56.48
23.50
29.82
45.17
collect
7.18
7.91
10.42
9.54
clone
0.06
0.09
0.11
0.51
Nanoseconds per operation, median of criterion's samples. ★ marks the fastest decimal. Lower is better.