Skip to content

Commit 7c24452

Browse files
committed
Add benchmarks
1 parent dc0a851 commit 7c24452

File tree

8 files changed

+11600
-8
lines changed

8 files changed

+11600
-8
lines changed

.github/workflows/tests.yml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,49 @@ jobs:
1111
runs-on: ubuntu-18.04
1212
steps:
1313
- name: Cancel Previous Runs
14-
uses: styfle/cancel-workflow-action@0.6.0
14+
uses: styfle/cancel-workflow-action@0.10.0
1515
with:
1616
access_token: ${{ github.token }}
17-
- uses: actions/checkout@v2
18-
- uses: actions/setup-python@v2
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.10'
1921
- name: install clang-format
2022
if: steps.clang_format.outputs.cache-hit != 'true'
2123
run: |
2224
sudo apt-get remove -y clang-6.0 libclang-common-6.0-dev libclang1-6.0 libllvm6.0
2325
sudo apt-get autoremove
2426
sudo apt-get install clang-format clang-format-6.0
25-
- uses: pre-commit/action@v2.0.0
27+
- uses: pre-commit/action@v3.0.0
28+
29+
benchmark:
30+
name: Benchmark
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Cancel Previous Runs
34+
uses: styfle/cancel-workflow-action@0.10.0
35+
- uses: actions/checkout@v3
36+
- uses: actions/setup-python@v4
37+
with:
38+
python-version: '3.10'
39+
cache: 'pip'
40+
cache-dependency-path: python/requirements/development.txt
41+
- name: Install deps
42+
run: pip install -r python/requirements/development.txt
43+
- name: Build module
44+
run: |
45+
cd python
46+
python setup.py build_ext --inplace
47+
- name: Run benchmarks
48+
run: |
49+
cd python/benchmark
50+
pip uninstall -y tskit
51+
python run.py
52+
- name: Upload Results
53+
uses: actions/upload-artifact@v2
54+
with:
55+
name: benchmark-results
56+
path: python/benchmark
2657

2758
test:
2859
name: Python
@@ -37,12 +68,12 @@ jobs:
3768
shell: bash
3869
steps:
3970
- name: Cancel Previous Runs
40-
uses: styfle/cancel-workflow-action@0.6.0
71+
uses: styfle/cancel-workflow-action@0.10.0
4172
with:
4273
access_token: ${{ github.token }}
4374

4475
- name: Checkout
45-
uses: actions/checkout@v2
76+
uses: actions/checkout@v3
4677

4778
- name: Cache conda and dependencies
4879
id: cache
@@ -143,12 +174,12 @@ jobs:
143174
shell: msys2 {0}
144175
steps:
145176
- name: Cancel Previous Runs
146-
uses: styfle/cancel-workflow-action@0.6.0
177+
uses: styfle/cancel-workflow-action@0.10.0
147178
with:
148179
access_token: ${{ github.token }}
149180

150181
- name: 'Checkout'
151-
uses: actions/checkout@v2
182+
uses: actions/checkout@v3
152183

153184
- name: Setup MSYS2 ${{matrix.sys}}
154185
uses: msys2/setup-msys2@v2

docs/development.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,45 @@ pre-commit installed at .git/hooks/pre-commit
10761076
```
10771077

10781078

1079+
## Benchmarking
1080+
1081+
Tskit has a simple benchmarking tool to help keep track of performance.
1082+
1083+
### Running benchmarks
1084+
1085+
The benchmark suite can be run with:
1086+
1087+
```bash
1088+
> cd python/benchmark
1089+
> python run.py
1090+
```
1091+
1092+
Results are written to `bench-results.json` in the same folder. Note that if any version of `tskit`
1093+
is installed then that will be used for the benchmarking. To use the local development version of
1094+
tskit ensure you have `pip uninstall tskit` before running the benchmarking. The version used is
1095+
shown in the header of the report.
1096+
1097+
### Adding a new benchmark
1098+
1099+
The benchmarks are specified by the `config.yaml` file in `python/benchmark`. To add a new benchmark
1100+
add an entry to the `benchmarks` dictionary. For example:
1101+
1102+
```yaml
1103+
- code: do_my_thing({option_name})
1104+
setup: |
1105+
import a_module
1106+
name: my_benchmark #optional, the code is used by default
1107+
parameters:
1108+
option_name:
1109+
- "reticulate_splines"
1110+
- "foobar"
1111+
```
1112+
1113+
Strings are interpreted as Python f-strings, so you can use the `parameters` dictionary to provide
1114+
values that will be interpolated into both the `setup` and `code` strings.
1115+
1116+
The suite can be run for all released versions with the `run-for-all-releases.py` script.
1117+
10791118
## Releasing a new version
10801119

10811120
Tskit maintains separate versioning for the C API and Python package, each has its own
@@ -1113,6 +1152,8 @@ e.g. 1.0.0b1. Update the Python CHANGELOG.rst, ensuring that all significant
11131152
changes since the last release have been listed. Comparing
11141153
`git log --follow --oneline -- python`
11151154
with `git log --follow --oneline -- python/CHANGELOG.rst` may help here.
1155+
Once the version number is updated run the benchmarks as detailed above and
1156+
commit the `bench-results.json/html` files.
11161157
Once this PR is merged, push a tag to github:
11171158

11181159
```bash

python/benchmark/bench-results.html

Lines changed: 121 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)