Skip to content

Commit

Permalink
feat(ci): add codespeedHQ performance analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelZe committed Jan 14, 2024
1 parent 412f246 commit 588ee96
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ jobs:
env_vars: OS,PYTHON
fail_ci_if_error: true
verbose: true
- name: Run benchmarks
uses: CodSpeedHQ/action@v2
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: pixi run test --codspeed
3 changes: 2 additions & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ channels = ["conda-forge"]
platforms = ["win-64", "linux-64"]

[tasks]
postinstall = "pip install --upgrade --no-build-isolation --no-deps --disable-pip-version-check -e ."
# install packages not on conda-forge
postinstall = "pip install --upgrade --no-build-isolation --no-deps --disable-pip-version-check -e .; pip install pytest-codspeed mkdocs-bibtex"
doc = "mkdocs serve"
test = "pytest -v tests/ --cov=src --cov-report=xml"
lint = "pre-commit run --all"
Expand Down
11 changes: 11 additions & 0 deletions tests/test_classical_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ def _apply_rule(
)
assert (y_pred == y_test).all()

@pytest.mark.benchmark()
@pytest.mark.parametrize("subset", ["all", "ex"])
def test_tick_rule(self, x_train: pd.DataFrame, subset: str) -> None:
"""Test, if tick rule is correctly applied.
Expand All @@ -323,6 +324,7 @@ def test_tick_rule(self, x_train: pd.DataFrame, subset: str) -> None:
y_test = pd.Series([-1, 1, 1, -1])
self._apply_rule(x_train, x_test, y_test, [("tick", subset)], 7)

@pytest.mark.benchmark()
@pytest.mark.parametrize("subset", ["all", "ex"])
def test_rev_tick_rule(self, x_train: pd.DataFrame, subset: str) -> None:
"""Test, if rev. tick rule is correctly applied.
Expand All @@ -341,6 +343,7 @@ def test_rev_tick_rule(self, x_train: pd.DataFrame, subset: str) -> None:
y_test = pd.Series([-1, 1, 1, -1])
self._apply_rule(x_train, x_test, y_test, [("rev_tick", subset)], 7)

@pytest.mark.benchmark()
@pytest.mark.parametrize("subset", ["best", "ex"])
def test_quote_rule(self, x_train: pd.DataFrame, subset: str) -> None:
"""Test, if quote rule is correctly applied.
Expand All @@ -366,6 +369,7 @@ def test_quote_rule(self, x_train: pd.DataFrame, subset: str) -> None:
y_test = pd.Series([-1, 1, 1, -1, -1, 1])
self._apply_rule(x_train, x_test, y_test, [("quote", subset)], 45)

@pytest.mark.benchmark()
@pytest.mark.parametrize("subset", ["best", "ex"])
def test_lr(self, x_train: pd.DataFrame, subset: str) -> None:
"""Test, if the lr algorithm is correctly applied.
Expand All @@ -389,6 +393,7 @@ def test_lr(self, x_train: pd.DataFrame, subset: str) -> None:
y_test = pd.Series([-1, 1, 1, -1])
self._apply_rule(x_train, x_test, y_test, [("lr", subset)], 7)

@pytest.mark.benchmark()
@pytest.mark.parametrize("subset", ["best", "ex"])
def test_rev_lr(self, x_train: pd.DataFrame, subset: str) -> None:
"""Test, if the rev. lr algorithm is correctly applied.
Expand Down Expand Up @@ -419,6 +424,7 @@ def test_rev_lr(self, x_train: pd.DataFrame, subset: str) -> None:
y_test = pd.Series([-1, 1, 1, -1, -1, 1])
self._apply_rule(x_train, x_test, y_test, [("rev_lr", subset)], 42)

@pytest.mark.benchmark()
@pytest.mark.parametrize("subset", ["best", "ex"])
def test_emo(self, x_train: pd.DataFrame, subset: str) -> None:
"""Test, if the emo algorithm is correctly applied.
Expand Down Expand Up @@ -449,6 +455,7 @@ def test_emo(self, x_train: pd.DataFrame, subset: str) -> None:
y_test = pd.Series([-1, 1, 1, -1, -1, 1])
self._apply_rule(x_train, x_test, y_test, [("emo", subset)], 42)

@pytest.mark.benchmark()
@pytest.mark.parametrize("subset", ["best", "ex"])
def test_rev_emo(self, x_train: pd.DataFrame, subset: str) -> None:
"""Test, if the rev. emo algorithm is correctly applied.
Expand Down Expand Up @@ -479,6 +486,7 @@ def test_rev_emo(self, x_train: pd.DataFrame, subset: str) -> None:
y_test = pd.Series([-1, 1, 1, -1, -1, 1])
self._apply_rule(x_train, x_test, y_test, [("rev_emo", subset)], 42)

@pytest.mark.benchmark()
@pytest.mark.parametrize("subset", ["best", "ex"])
def test_clnv(self, x_train: pd.DataFrame, subset: str) -> None:
"""Test, if the clnv algorithm is correctly applied.
Expand Down Expand Up @@ -509,6 +517,7 @@ def test_clnv(self, x_train: pd.DataFrame, subset: str) -> None:
y_test = pd.Series([1, -1, 1, -1, 1, -1])
self._apply_rule(x_train, x_test, y_test, [("clnv", subset)], 42)

@pytest.mark.benchmark()
@pytest.mark.parametrize("subset", ["best", "ex"])
def test_rev_clnv(self, x_train: pd.DataFrame, subset: str) -> None:
"""Test, if the rev. clnv algorithm is correctly applied.
Expand Down Expand Up @@ -538,6 +547,7 @@ def test_rev_clnv(self, x_train: pd.DataFrame, subset: str) -> None:
y_test = pd.Series([1, -1, 1, -1, 1, -1])
self._apply_rule(x_train, x_test, y_test, [("rev_clnv", subset)], 5)

@pytest.mark.benchmark()
def test_trade_size(self, x_train: pd.DataFrame) -> None:
"""Test, if the trade size algorithm is correctly applied.
Expand All @@ -558,6 +568,7 @@ def test_trade_size(self, x_train: pd.DataFrame) -> None:
y_test = pd.Series([-1, 1, -1, 1, -1, 1])
self._apply_rule(x_train, x_test, y_test, [("trade_size", "ex")], 42)

@pytest.mark.benchmark()
def test_depth(self, x_train: pd.DataFrame) -> None:
"""Test, if the depth rule is correctly applied.
Expand Down

0 comments on commit 588ee96

Please sign in to comment.