Add benchmark comparing against fpdec
crate
#14
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contains benchmarks comparing this crate against
fpdec
(the previous performance champion AFAIK),both on primitive operations and real-world uses.
TLDR:
Using
const_decimal::Decimal<i32, _>
vsfpdec::Decimal
for inverse futures pnl calculation gives a staggering improvement of 45x and ~15x better when usingi64
datatype.Also
fpdec::Decimal
is 32 bytes in size vs 4 (i32) and 8 (i64) respectively forconst_decimal::Decimal
which is nicer for fast CPU caches.I added
black_box
everywhere to avoid any sneaky optimizations by the compiler. Maybe overkill, but idk :)Example output of
cargo bench vs_fpdec
show the following on anAMD EPYC 9654 (192) @ 2.400GHz
: