Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

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.