The Reactive C++ Toolbox is an open source library of C++20 components designed for efficient, asynchronous network applications on the Linux platform.
Note to reviewers: This pull request consists of 2 commits, so view separately for easier reviewing.
The first commit changes how dec_digits is benchmarked (i.e. using randomly generated numbers).
In this commit, you may notice K=7 for the benchmarks. This means that 1 to 7 digit random numbers will be used for benchmarking i.e. [1, 10^7). The reasoning for that is because I think very large numbers (>7 digits) are much less common in production.
Note to reviewers: This pull request consists of 2 commits, so view separately for easier reviewing.
The first commit changes how dec_digits is benchmarked (i.e. using randomly generated numbers).
In this commit, you may notice K=7 for the benchmarks. This means that 1 to 7 digit random numbers will be used for benchmarking i.e. [1, 10^7). The reasoning for that is because I think very large numbers (>7 digits) are much less common in production.
BEFORE commit (baseline results):
Note that the results indicate dec_digits_less is faster than than the dec_digits_lib by 1.05x (i.e. 5%)
AFTER commit (K=7):
Now, the benchmark shows dec_digits_lib is faster than dec_digits_less by 1.3x when dealing with integers up to 10^7.
AFTER commit (K=19).
Adding K=19 benchmark results here if anyone is curious how dec_digits performs when dealing with integers of all digit sizes possible (for int64).
But when dealing all integers up to 10^19, dec_digits_less takes the lead again -- 10% faster than it's rival.
The second commit provides a faster implementation of dec_digits along with support for negative integers.
Results with new implementation (K=7):
The previous dec_digits_lib is now dec_digits_branch.
New dec_digits unsigned overload is about 9.6x faster than previous. And the signed overload is about 7.6x faster.
Results with new implementation (K=19):
Unsigned overload about 16x faster. Signed overload about 12.8x faster