-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: add visibility benchmark and codspeed integration
- Loading branch information
Showing
7 changed files
with
2,062 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: CodSpeed | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Run on pushes to the main branch | ||
pull_request: # Run on all pull requests | ||
|
||
jobs: | ||
codspeed: | ||
name: Run benchmarks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.13" | ||
- name: Generate virtual environment | ||
run: python -m venv .venv | ||
- name: Build Python wrapper | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
command: develop | ||
args: --release --extras dev -m crates/lox-space/Cargo.toml | ||
- uses: CodSpeedHQ/action@v3 | ||
with: | ||
run: | | ||
. .venv/bin/activate | ||
pytest crates/lox-space/tests/ --codspeed | ||
token: ${{ secrets.CODSPEED_TOKEN }} # Optional for public repositories |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
.DS_Store | ||
flamegraph.svg | ||
.mise.local.toml | ||
.codspeed/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ dev = [ | |
"ipython", | ||
"numpy", | ||
"pytest", | ||
"pytest-codspeed", | ||
] | ||
|
||
[build-system] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) 2024. Helge Eichhorn and the LOX contributors | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
import itertools | ||
import pytest | ||
|
||
import lox_space as lox | ||
|
||
|
||
@pytest.mark.benchmark() | ||
def test_visibility_benchmark(provider, oneweb, estrack): | ||
mask = lox.ElevationMask.fixed(0) | ||
t0 = next(iter(oneweb.values())).states()[0].time() | ||
times = [t0 + t for t in lox.TimeDelta.range(0, 86400, 3000)] | ||
|
||
passes = {} | ||
|
||
for (gs_name, gs), (sc_name, sc) in filter( | ||
lambda pair: isinstance(pair[0][1], lox.GroundLocation) | ||
and isinstance(pair[1][1], lox.Trajectory), | ||
itertools.combinations(itertools.chain(estrack.items(), oneweb.items()), 2), | ||
): | ||
assert isinstance(gs, lox.GroundLocation) | ||
assert isinstance(sc, lox.Trajectory) | ||
|
||
if not sc_name in passes: | ||
passes[sc_name] = {} | ||
|
||
passes[sc_name][gs_name] = lox.visibility(times, gs, mask, sc, provider) | ||
|
||
assert len(passes) == len(oneweb) | ||
for sc_passes in passes.values(): | ||
assert len(sc_passes) == len(estrack) |
Oops, something went wrong.