Skip to content

Latest commit

 

History

History
60 lines (41 loc) · 1.64 KB

File metadata and controls

60 lines (41 loc) · 1.64 KB

Python example for benchmarking with pytest-benchmark

This directory shows how to use github-action-benchmark with pytest-benchmark.

Run benchmarks

Official documentation for usage of pytest-benchmark:

https://pytest-benchmark.readthedocs.io/en/stable/

Install dependencies with venv package using Python3.

$ python -m venv venv
$ source venv/bin/activate
$ pip install pytest pytest-benchmark

Prepare bench.py as follows:

e.g.

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.

- 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.

- name: Store benchmark result
  uses: benchmark-action/github-action-benchmark@v1
  with:
    tool: 'pytest'
    output-file-path: output.json

Please read 'How to use' section for common usage.