diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 658baafff..fd7a3911c 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -67,6 +67,20 @@ jobs: run: pyright - name: Test with tox run: tox -e py + - name: Store benchmark result + uses: benchmark-action/github-action-benchmark@v1 + with: + name: Python Benchmark with pytest-benchmark + tool: 'pytest' + output-file-path: ./tests/benchmark-${{ matrix.python }}.json + # Use personal access token instead of GITHUB_TOKEN due to https://github.community/t/github-action-not-triggering-gh-pages-upon-push/16096 + github-token: ${{ secrets.GITHUB_TOKEN }} + auto-push: true + # Show alert with commit comment on detecting possible performance regression + alert-threshold: '150%' + comment-on-alert: true + fail-on-alert: true + alert-comment-cc-users: '@pcriadoperez' - name: Coveralls Parallel uses: coverallsapp/github-action@v2 with: diff --git a/test-requirements.txt b/test-requirements.txt index ec3e381ae..8687b7b55 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,6 +4,7 @@ pytest-asyncio pytest-cov pytest-xdist pytest-rerunfailures +pytest-benchmark requests-mock tox setuptools diff --git a/tests/benchmark-3.10.json b/tests/benchmark-3.10.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/tests/benchmark-3.10.json @@ -0,0 +1 @@ +{} diff --git a/tests/benchmark-3.11.json b/tests/benchmark-3.11.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/tests/benchmark-3.11.json @@ -0,0 +1 @@ +{} diff --git a/tests/benchmark-3.12.json b/tests/benchmark-3.12.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/tests/benchmark-3.12.json @@ -0,0 +1 @@ +{} diff --git a/tests/benchmark-3.7.json b/tests/benchmark-3.7.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/tests/benchmark-3.7.json @@ -0,0 +1 @@ +{} diff --git a/tests/benchmark-3.8.json b/tests/benchmark-3.8.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/tests/benchmark-3.8.json @@ -0,0 +1 @@ +{} diff --git a/tests/benchmark-3.9.json b/tests/benchmark-3.9.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/tests/benchmark-3.9.json @@ -0,0 +1 @@ +{} diff --git a/tests/test_ws_api.py b/tests/test_ws_api.py index 20a098875..107fd32e3 100644 --- a/tests/test_ws_api.py +++ b/tests/test_ws_api.py @@ -15,6 +15,12 @@ async def test_ws_api_public_endpoint(clientAsync): order_book = await clientAsync.ws_get_order_book(symbol="BTCUSDT") assert_ob(order_book) +@pytest.mark.asyncio +@pytest.mark.benchmark(group="ws_api") +async def test_benchmark_ws_api_get_order_book(clientAsync, benchmark): + """Test normal order book request""" + order_book = await benchmark(clientAsync.ws_get_order_book, symbol="BTCUSDT") + assert_ob(order_book) @pytest.mark.asyncio async def test_ws_api_private_endpoint(clientAsync):