Skip to content

Commit

Permalink
Add comment on how to write benchmarking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanielRN committed Dec 10, 2020
1 parent a7485ba commit de3277a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ Performance progression of benchmarks for packages distributed by OpenTelemetry

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.

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

```python
def test_simple_start_span(benchmark):
def benchmark_start_as_current_span(span_name, attribute_num):
span = tracer.start_span(
span_name,
attributes={"count": attribute_num},
)
span.end()

benchmark(benchmark_start_as_current_span, "benchmarkedSpan", 42)
```

Make sure the test file is under the `tests/performance/benchmarks/` folder of
the package it is benchmarking and further has a path that corresponds to the
file in the package it is testing. Make sure that the file name begins with
`test_benchmark_`. (e.g. `opentelemetry-sdk/tests/performance/benchmarks/propagation/test_benchmark_b3_format.py`)

## Pull Requests

### How to Send Pull Requests
Expand Down

0 comments on commit de3277a

Please sign in to comment.