https://github.com/liarprincess/swift-bigint-performance-tests
https://github.com/liarprincess/swift-bigint-performance-tests
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/liarprincess/swift-bigint-performance-tests
- Owner: LiarPrincess
- Created: 2023-02-03T16:59:30.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-21T08:24:17.000Z (over 3 years ago)
- Last Synced: 2025-02-27T09:59:11.119Z (over 1 year ago)
- Language: Python
- Size: 255 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Swift `BigInt` performance tests
This project runs performance tests for `BigInt` implementations from:
- `swift_numerics` - [this branch](https://github.com/LiarPrincess/swift-numerics/tree/13-Performance)
- `Violet` - [this branch](https://github.com/LiarPrincess/Violet/tree/swift-numerics) which is a `main` branch with all `swift_numerics` tests from all PRs
- optimized for `Int32` range. In this tests only `0`, `-1` and `1` fall into this range, so it should not matter.
- `Violet XsProMax` - [this branch](https://github.com/LiarPrincess/Violet-BigInt-XsProMax). Violet implementation with following changes:
- no small inlined integer - magnitude is always stored on the heap
- no restrictions on the size - `isNegative` is stored in-line (and not on the heap like in Violet); `count` and `capacity` are on the heap because I don't want to stray too much from `Violet`.
- `attaswift` - [this branch](https://github.com/LiarPrincess/BigInt/tree/Performance-tests) which is a `main` branch with added performance tests
## Content
- `__main__.py` - main script to run tests; most of the time you will use this
- `multiple_run.py` - run tests multiple times in a loop; useful to combat random relative standard deviation spikes
- `multiple_group_by_test.py` - process results from `multiple_run.py`, so that they are grouped by test (instead of per run)
## How to read the results
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.
## How to run
1. Clone all of the implementations mentioned above
2. Open `__main__.py` and modify:
```py
# 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 = '…'
```
3. Select which implementations to run:
```py
# 1st entry is a reference implementation,
# all of the others will be compared with it.
IMPLEMENTATIONS = (
SWIFT_NUMERICS,
VIOLET,
ATTASWIFT,
)
```
4. Run `python3 .` in main dir (or F5 in VSCode)