-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BigInt tests][No merge] 🐰 How NOT to write performance tests #256
base: biginteger
Are you sure you want to change the base?
Conversation
I wrote a test script that runs multiple
Platform:
Important:
stringThis test involved Parsing from string:
To string:
equal/compareThis test involved
unaryThis test involved Plus:
Minus:
Invert:
add, subThis test involved Add:
Sub:
mul, div, modThis test involved Mul:
Div/mod:
and, or, xorThis test involved
shiftThis test involved shifting 20_203 Left:
Right:
piThis test was suggested by Xiaodi Wu (@xwu) in BigInt #120, so we may ask them if we have any questions (maybe?). In theory it looks interesting, because it contains In practice count 5000 has following input distribution (more detailed results here):
Anyway, here are the results: Results (looking at the 5000 test):
As for the TLDR; Conclusions
|
Update 21.2.2023:
Anyway, from those tests we can see that
Obviously you can quite easily write something that will be faster than Violet. Violet is heavily geared towards small integers ( |
Update 20.3.2023:
|
Please read the #242 Using tests from “Violet - Python VM written in Swift” before.
=== DO NOT MERGE! Discussion only. ===
🐰 Discussion
Those are the all of the basic operations. In the future we may add some more targeted tests for interesting operations (
mul
/div
), but for now this should be enough.It may also be a good idea to move all of the performance tests to a separate test target. Currently I am using
PERFORMANCE_TEST
compilation flag.You can use Violet as a baseline measure, thought Violet was heavily optimized for
Int32
range (see documentation). I could easily write something faster, but this is not my use-case.String parsing
That said, I have to say that I find the
String
parsing performance quite bad. From my tests Violet is ~30 times faster.Violet secret:
Implemented here. Should I create an issue for this?
Mac
I have 2014 rMBP -> mac 11.7 (Big Sur), Xcode 13.2.1, Intel. I assume that 9 years old machines are not exactly a priority for 🍎. Executing all of those tests take ~30 min (serial execution,
DEBUG
), and I can't be bothered to re-run them properly since it will throttle after a few minutes anyway…Linux
Normally it would fail to compile:
But I wrote my own thing. Results below.