troy benchmarks

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.

0102030ns1481218192226Significant digits in the textf64 at 1 digits: 3.67 nsf64 at 4 digits: 5.45 nsf64 at 8 digits: 7.44 nsf64 at 12 digits: 9.79 nsf64 at 18 digits: 10.39 nsf64 at 19 digits: 10.75 nsf64 at 22 digits: 29.24 nsf64 at 26 digits: 30.09 nsf64Dec at 1 digits: 3.90 nsDec at 4 digits: 5.79 nsDec at 8 digits: 7.89 nsDec at 12 digits: 10.25 nsDec at 18 digits: 14.60 nsDec at 19 digits: 15.40 nsDec at 22 digits: 20.39 nsDec at 26 digits: 27.42 nsDecrust_decimal at 1 digits: 9.56 nsrust_decimal at 4 digits: 10.35 nsrust_decimal at 8 digits: 12.71 nsrust_decimal at 12 digits: 13.77 nsrust_decimal at 18 digits: 17.23 nsrust_decimal at 19 digits: 20.42 nsrust_decimal at 22 digits: 26.70 nsrust_decimal at 26 digits: 30.78 nsrust_decimalfastnum at 1 digits: 14.19 nsfastnum at 4 digits: 14.96 nsfastnum at 8 digits: 15.54 nsfastnum at 12 digits: 16.33 nsfastnum at 18 digits: 18.53 nsfastnum at 19 digits: 22.07 nsfastnum at 22 digits: 25.83 nsfastnum at 26 digits: 27.90 nsfastnum

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.

050100ns1481218192226Significant digits in the valueDec at 1 digits: 12.71 nsDec at 4 digits: 21.55 nsDec at 8 digits: 24.66 nsDec at 12 digits: 28.26 nsDec at 18 digits: 33.07 nsDec at 19 digits: 33.98 nsDec at 22 digits: 37.44 nsDec at 26 digits: 42.84 nsDecrust_decimal at 1 digits: 19.67 nsrust_decimal at 4 digits: 23.52 nsrust_decimal at 8 digits: 35.09 nsrust_decimal at 12 digits: 46.54 nsrust_decimal at 18 digits: 60.17 nsrust_decimal at 19 digits: 62.95 nsrust_decimal at 22 digits: 70.11 nsrust_decimal at 26 digits: 80.08 nsrust_decimalfastnum at 1 digits: 34.53 nsfastnum at 4 digits: 48.17 nsfastnum at 8 digits: 53.63 nsfastnum at 12 digits: 68.38 nsfastnum at 18 digits: 90.51 nsfastnum at 19 digits: 93.96 nsfastnum at 22 digits: 90.82 nsfastnum at 26 digits: 105.53 nsfastnum

Summary

The same numbers as one table.

operationf64Decrust_decimalfastnum
cmp0.100.313.344.29
add0.390.851.768.01
mul0.163.336.134.39
div0.7716.9326.5877.45
round_dp0.914.1813.357.47
round_to_step1.043.3324.0619.73
floor1.023.526.689.86
ceil1.013.987.6814.43
to_f641.3517.011.88
from_f648.9380.9075.78
parse6.497.3010.8115.39
format56.4823.5029.8245.17
collect7.187.9110.429.54
clone0.060.090.110.51
Nanoseconds per operation, median of criterion's samples. ★ marks the fastest decimal. Lower is better.