-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
describe pytest-benchmark support in docs
- Loading branch information
Showing
2 changed files
with
74 additions
and
9 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
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,60 @@ | ||
Python example for benchmarking with [pytest-benchmark][tool] | ||
============================================================= | ||
|
||
- [Workflow for this example](TODO) | ||
- [Action log of this example](TODO) | ||
- [Benchmark results on GitHub pages](https://rhysd.github.io/github-action-benchmark/dev/bench/) | ||
|
||
This directory shows how to use [`github-action-benchmark`](https://github.com/rhysd/github-action-benchmark) | ||
with [pytest-benchmark][tool]. | ||
|
||
## Run benchmarks | ||
|
||
Official documentation for usage of pytest-benchmark: | ||
|
||
https://pytest-benchmark.readthedocs.io/en/stable/ | ||
|
||
Install dependencies with `venv` package using Python3. | ||
|
||
```sh | ||
$ python -m venv venv | ||
$ source venv/bin/activate | ||
$ pip install pytest pytest-benchmark | ||
``` | ||
|
||
Prepare `bench.py` as follows: | ||
|
||
e.g. | ||
|
||
```python | ||
import pytest | ||
|
||
def some_test_case(benchmark): | ||
benchmark(some_func, args) | ||
``` | ||
|
||
And run benchmarks with `--benchmark-json` in workflow. The JSON file will be an input to | ||
github-action-benchmark. | ||
|
||
e.g. | ||
|
||
```yaml | ||
- name: Run benchmark | ||
run: pytest bench.py --benchmark-json output.json | ||
``` | ||
## Process benchmark results | ||
Store the benchmark results with step using the action. Please set `pytest` to `tool` input. | ||
|
||
```yaml | ||
- name: Store benchmark result | ||
uses: rhysd/github-action-benchmark@v1 | ||
with: | ||
tool: 'pytest' | ||
output-file-path: output.json | ||
``` | ||
|
||
Please read ['How to use' section](https://github.com/rhysd/github-action-benchmark#how-to-use) for common usage. | ||
|
||
[tool]: https://pypi.org/project/pytest-benchmark/ |