-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
134 additions
and
2 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,62 @@ | ||
name: Benchmark | ||
env: | ||
PYTHONHASHSEED: "0" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
- epic/* | ||
workflow_dispatch: | ||
inputs: | ||
specific-pip-packages: | ||
description: Run benchmarks with specific pip packages | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
benchmark: | ||
name: Performance regression | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ComPWA/actions/pip-install@v1 | ||
with: | ||
editable: "yes" | ||
extras: test,all | ||
python-version: "3.9" | ||
specific-packages: ${{ inputs.specific-pip-packages }} | ||
- name: Run pytest-benchmark | ||
run: | | ||
pytest \ | ||
-k benchmark \ | ||
--benchmark-json output.json \ | ||
--durations=0 | ||
working-directory: benchmarks | ||
- name: Store result | ||
if: github.event_name == 'push' | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: AmpForm benchmark results | ||
tool: pytest | ||
output-file-path: benchmarks/output.json | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
gh-pages-branch: benchmark-results | ||
benchmark-data-dir-path: "" | ||
auto-push: true | ||
- name: Warn on performance decrease | ||
if: github.event_name == 'pull_request' | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: AmpForm benchmark results | ||
tool: pytest | ||
output-file-path: benchmarks/output.json | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
gh-pages-branch: benchmark-results | ||
benchmark-data-dir-path: "" | ||
auto-push: false | ||
comment-on-alert: true | ||
fail-on-alert: true |
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
Empty file.
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,6 @@ | ||
from _pytest.config import Config | ||
|
||
|
||
def pytest_configure(config: Config): | ||
# cspell:ignore addinivalue | ||
config.addinivalue_line("python_files", "*.py") |
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,37 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
import qrules | ||
|
||
import ampform | ||
from ampform.dynamics.builder import create_relativistic_breit_wigner_with_ff | ||
|
||
if TYPE_CHECKING: | ||
import sympy as sp | ||
from pytest_benchmark.fixture import BenchmarkFixture | ||
|
||
|
||
@pytest.mark.benchmark(group="doit", min_rounds=1) | ||
def test_doit_speed(benchmark: BenchmarkFixture): | ||
reaction = qrules.generate_transitions( | ||
initial_state=("psi(4160)", [-1, +1]), | ||
final_state=["D-", "D0", "pi+"], | ||
allowed_intermediate_particles=["D*(2007)0"], | ||
formalism="canonical-helicity", | ||
) | ||
builder = ampform.get_builder(reaction) | ||
for particle in reaction.get_intermediate_particles(): | ||
builder.dynamics.assign(particle.name, create_relativistic_breit_wigner_with_ff) | ||
model = builder.formulate() | ||
|
||
intensity_expr = benchmark(_perform_doit, model.expression) | ||
undefined_symbols = intensity_expr.free_symbols | ||
undefined_symbols -= set(model.parameter_defaults) | ||
undefined_symbols -= set(model.kinematic_variables) | ||
assert not undefined_symbols | ||
|
||
|
||
def _perform_doit(expr: sp.Expr): | ||
return expr.doit() |
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
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