Skip to main content

A pytest plugin to get durations on a per-function basis and per module basis.

Project description

pytest-extra-durations

Get more info about the speed of your test suite.

It works with pytest-xdist too.

Installation

You can install "pytest-extra-durations" via pip:

pip install pytest-extra-durations

Usage

This plugin provides three types of information.

The sum of all tests/setup/teardown durations

This can give you more info than the total time displayed by pytest because it's not influenced by the number of workers in pytest-dist, or the collection time.

Exemple:

============== Sum of all tests durations ===============
1.95s

This will be displayed all the time and can't be turned off unless you uninstall this plugin.

The sum of all the tests durations of a module

This will tell you how much time it took to execute all the tests in a given file. The API is similar to the one of --durations in the Pytest CLI.

pytest --modules-durations=4 ./path/to/test/directory

gives:

=============== slowest 4 modules durations =============
1.17s tensorflow_addons/activations/tests/sparsemax_test.py
0.28s tensorflow_addons/activations/tests/gelu_test.py
0.10s tensorflow_addons/activations/tests/softshrink_test.py
0.09s tensorflow_addons/activations/tests/rrelu_test.py

The sum of all the tests durations of a test function

A test function can produce multiple tests, that can be executed on different workers too. This will sum the durations of all tests, setups and teardown produced by a single test function, and report the slower ones.

The API is similar to the one of --durations in the Pytest CLI.

pytest --functions-durations=4 ./path/to/test/directory

gives:

============ slowest test functions =============
0.99s tensorflow_addons/activations/tests/sparsemax_test.py::test_gradient_against_estimate
0.17s tensorflow_addons/activations/tests/gelu_test.py::test_same_as_py_func
0.09s tensorflow_addons/activations/tests/softshrink_test.py::test_same_as_py_func
0.08s tensorflow_addons/activations/tests/gelu_test.py::test_gelu
0.08s tensorflow_addons/activations/tests/rrelu_test.py::test_theoretical_gradients

TODO:

  • Integration with line_profiler
  • Add tests (the ones present are dummy ones)
  • Automatic upload to pypi with github actions
  • Running the tests in github actions

License

Distributed under the terms of the MIT_ license, "pytest-extra-durations" is free and open source software

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-extra-durations-0.1.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

pytest_extra_durations-0.1.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest-extra-durations-0.1.2.tar.gz.

File metadata

  • Download URL: pytest-extra-durations-0.1.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for pytest-extra-durations-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0edc4c1384a926c7a7ed79a0af4b9274b31d4c63daaf91f7800dc1fad8d6ce28
MD5 73b631e29a10898122ca8efd380e8306
BLAKE2b-256 b999ae0eb40a8f2e93fe7d707a8b612105ffcd01dcb8017101ef23b443be7f54

See more details on using hashes here.

Provenance

File details

Details for the file pytest_extra_durations-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pytest_extra_durations-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for pytest_extra_durations-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3216a6aa6b2e0af3d3c26f522758fe8cb89d99a0318f4fe948196ffab846ffb4
MD5 c13ffdd5d57d404dfbd85503f9da02a8
BLAKE2b-256 fe4d15041fa2df95425cee139c6bf55f3d4526d89cb415c264b6c121750b52c0

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page