This project runs performance tests for BigInt implementations from:
swift_numerics- this branchViolet- this branch which is amainbranch with allswift_numericstests from all PRs- optimized for
Int32range. In this tests only0,-1and1fall into this range, so it should not matter.
- optimized for
Violet XsProMax- this branch. Violet implementation with following changes:- no small inlined integer - magnitude is always stored on the heap
- no restrictions on the size -
isNegativeis stored in-line (and not on the heap like in Violet);countandcapacityare on the heap because I don't want to stray too much fromViolet.
attaswift- this branch which is amainbranch with added performance tests
__main__.py- main script to run tests; most of the time you will use thismultiple_run.py- run tests multiple times in a loop; useful to combat random relative standard deviation spikesmultiple_group_by_test.py- process results frommultiple_run.py, so that they are grouped by test (instead of per run)
Values in parens mean relative performance improvement vs the 1st implementation. For example:
| 🐧 swift_numerics | 🐧 Violet | 🐧 attaswift | |
|---|---|---|---|
| test_string_fromRadix10 | 0.2386572415 | 0.011443098625 (20.9x) | 0.025662900375 (9.3x) |
Means that Violet is 20.9 times faster than swift_numerics and attaswift is 9.3 times faster.
If you want you can also set SHOW_RELATIVE_STANDARD_DEVIATION = True inside the script.
-
Clone all of the implementations mentioned above
-
Open
__main__.pyand modify:# Path to: https://github.com/LiarPrincess/swift-numerics/tree/13-Performance # Branch: 13-Performance SWIFT_NUMERICS_PATH = '…' # Path to: https://github.com/LiarPrincess/Violet/tree/swift-numerics # Branch: swift-numerics VIOLET_PATH = '…' # Path to: https://github.com/LiarPrincess/BigInt/tree/Performance-tests # Branch: Performance-tests ATTASWIFT_PATH = '…'
-
Select which implementations to run:
# 1st entry is a reference implementation, # all of the others will be compared with it. IMPLEMENTATIONS = ( SWIFT_NUMERICS, VIOLET, ATTASWIFT, )
-
Run
python3 .in main dir (or F5 in VSCode)