Skip to content

Commit 5ff46ac

Browse files
authored
Move benchmarks outside of tests directory (#2670)
Fixes #2669
1 parent c8e529e commit 5ff46ac

10 files changed

Lines changed: 18 additions & 58 deletions

File tree

.github/workflows/instrumentations_0.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,5 @@ jobs:
126126
.tox
127127
~/.cache/pip
128128
key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
129-
- name: run pytest without --benchmark-skip
129+
- name: run tox
130130
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra

.github/workflows/instrumentations_1.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ jobs:
2525
matrix:
2626
python-version: [py38, py39, py310, py311, py312, pypy3]
2727
package:
28-
# Only add here packages that do not have benchmark tests
2928
- "urllib"
3029
- "urllib3"
3130
- "wsgi"
3231
- "distro"
3332
- "richconsole"
3433
- "psycopg"
3534
- "prometheus-remote-write"
35+
- "sdk-extension-aws"
36+
- "propagator-aws-xray"
3637
- "propagator-ot-trace"
3738
- "resource-detector-azure"
3839
- "resource-detector-container"
@@ -58,5 +59,5 @@ jobs:
5859
.tox
5960
~/.cache/pip
6061
key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
61-
- name: run pytest without --benchmark-skip
62+
- name: run tox
6263
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra

.github/workflows/instrumentations_2.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ _build/
5858
# mypy
5959
.mypy_cache/
6060
target
61+
62+
# Benchmark result files
63+
*-benchmark.json

CONTRIBUTING.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ for more detail on available tox commands.
9696
9797
### Benchmarks
9898

99-
Performance progression of benchmarks for packages distributed by OpenTelemetry Python can be viewed as a [graph of throughput vs commit history](https://opentelemetry-python-contrib.readthedocs.io/en/latest/performance/benchmarks.html). From the linked page, you can download a JSON file with the performance results.
100-
101-
Running the `tox` tests also runs the performance tests if any are available. Benchmarking tests are done with `pytest-benchmark` and they output a table with results to the console.
99+
Some packages have benchmark tests. To run them, run `tox -f benchmark`. Benchmark tests use `pytest-benchmark` and they output a table with results to the console.
102100

103101
To write benchmarks, simply use the [pytest benchmark fixture](https://pytest-benchmark.readthedocs.io/en/latest/usage.html#usage) like the following:
104102

@@ -114,10 +112,10 @@ def test_simple_start_span(benchmark):
114112
benchmark(benchmark_start_as_current_span, "benchmarkedSpan", 42)
115113
```
116114

117-
Make sure the test file is under the `tests/performance/benchmarks/` folder of
115+
Make sure the test file is under the `benchmarks/` folder of
118116
the package it is benchmarking and further has a path that corresponds to the
119117
file in the package it is testing. Make sure that the file name begins with
120-
`test_benchmark_`. (e.g. `propagator/opentelemetry-propagator-aws-xray/tests/performance/benchmarks/trace/propagation/test_benchmark_aws_xray_propagator.py`)
118+
`test_benchmark_`. (e.g. `propagator/opentelemetry-propagator-aws-xray/benchmarks/trace/propagation/test_benchmark_aws_xray_propagator.py`)
121119

122120
## Pull Requests
123121

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest-benchmark==4.0.0

propagator/opentelemetry-propagator-aws-xray/tests/performance/benchmarks/test_benchmark_aws_xray_propagator.py renamed to propagator/opentelemetry-propagator-aws-xray/benchmarks/test_benchmark_aws_xray_propagator.py

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest-benchmark==4.0.0

sdk-extension/opentelemetry-sdk-extension-aws/tests/performance/benchmarks/trace/test_benchmark_aws_xray_ids_generator.py renamed to sdk-extension/opentelemetry-sdk-extension-aws/benchmarks/trace/test_benchmark_aws_xray_ids_generator.py

File renamed without changes.

tox.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ envlist =
2020
py3{8,9,10,11,12}-test-sdk-extension-aws
2121
pypy3-test-sdk-extension-aws
2222
lint-sdk-extension-aws
23+
benchmark-sdk-extension-aws
2324

2425
; opentelemetry-distro
2526
py3{8,9,10,11,12}-test-distro
@@ -314,6 +315,7 @@ envlist =
314315
py3{8,9,10,11,12}-test-propagator-aws-xray
315316
pypy3-test-propagator-aws-xray
316317
lint-propagator-aws-xray
318+
benchmark-propagator-aws-xray
317319

318320
; opentelemetry-propagator-ot-trace
319321
py3{8,9,10,11,12}-test-propagator-ot-trace
@@ -741,6 +743,7 @@ commands_pre =
741743
sdk-extension-aws: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk
742744
sdk-extension-aws: pip install opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils
743745
sdk-extension-aws: pip install -r {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws/test-requirements.txt
746+
benchmark-sdk-extension-aws: pip install -r {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws/benchmark-requirements.txt
744747

745748
resource-detector-container: pip install opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api
746749
resource-detector-container: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions
@@ -765,6 +768,7 @@ commands_pre =
765768
propagator-aws-xray: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk
766769
propagator-aws-xray: pip install opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils
767770
propagator-aws-xray: pip install -r {toxinidir}/propagator/opentelemetry-propagator-aws-xray/test-requirements.txt
771+
benchmark-propagator-aws-xray: pip install -r {toxinidir}/propagator/opentelemetry-propagator-aws-xray/benchmark-requirements.txt
768772

769773
processor-baggage: pip install opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api
770774
processor-baggage: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions
@@ -1094,6 +1098,7 @@ commands =
10941098
lint-sdk-extension-aws: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws
10951099
lint-sdk-extension-aws: flake8 --config {toxinidir}/.flake8 {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws
10961100
lint-sdk-extension-aws: sh -c "cd sdk-extension && pylint --rcfile ../.pylintrc opentelemetry-sdk-extension-aws"
1101+
benchmark-sdk-extension-aws: pytest {toxinidir}/sdk-extension/opentelemetry-sdk-extension-aws/benchmarks {posargs} --benchmark-json=sdk-extension-aws-benchmark.json
10971102

10981103
test-resource-detector-container: pytest {toxinidir}/resource/opentelemetry-resource-detector-container/tests {posargs}
10991104
lint-resource-detector-container: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/resource/opentelemetry-resource-detector-container
@@ -1118,6 +1123,7 @@ commands =
11181123
lint-propagator-aws-xray: isort --diff --check-only --settings-path {toxinidir}/.isort.cfg {toxinidir}/propagator/opentelemetry-propagator-aws-xray
11191124
lint-propagator-aws-xray: flake8 --config {toxinidir}/.flake8 {toxinidir}/propagator/opentelemetry-propagator-aws-xray
11201125
lint-propagator-aws-xray: sh -c "cd propagator && pylint --rcfile ../.pylintrc opentelemetry-propagator-aws-xray"
1126+
benchmark-propagator-aws-xray: pytest {toxinidir}/propagator/opentelemetry-propagator-aws-xray/benchmarks {posargs} --benchmark-json=propagator-aws-xray-benchmark.json
11211127

11221128
test-propagator-ot-trace: pytest {toxinidir}/propagator/opentelemetry-propagator-ot-trace/tests {posargs}
11231129
lint-propagator-ot-trace: black --diff --check --config {toxinidir}/pyproject.toml {toxinidir}/propagator/opentelemetry-propagator-ot-trace

0 commit comments

Comments
 (0)