Skip to main content

A timer for the phases of Pytest's execution.

Project description

pytest-execution-timer

A plugin to use with Pytest to measure execution time of tests.

Distinctly different from the --durations option of pytest, this plugin measures specific pytest startup/collection phases.

Leverages pytest hooks to measure execution time of phases.


Installation

Requires:

  • Python 3.7 or later.
  • Pytest 6.2 or later.

Install the plugin with any approach for your project.

Some examples:

pip install pytest-execution-timer
poetry add --dev pytest-execution-timer
pipenv install --dev pytest-execution-timer

Or add it to your requirements.txt file.

Usage

Enable the plugin with the --execution-timer option when running pytest:

$ pytest --execution-timer
...
Durations of pytest phases in seconds (min 100ms):
0.662	pytest_runtestloop

Control the threshold (default 100ms) by passing --minimum-duration=<value in ms>:

$ pytest --execution-timer --minimum-duration=1000  # 1 second

Understanding the output

The best ay to start is to compare the difference of the pytest_runtestloop duration and the overall duration of the test run. Example:

Durations of pytest phases in seconds (min 100ms):
0.666	pytest_runtestloop
====== 4 passed in 0.68s ======

In this example, there's not much lost between the test run and the pytest_runtestloop meaning that the startup and collection phases are not taking too much time.

If there's a larger difference in the timings, look to other emitted phases to understand what's taking the most time.

These can then be examined directly, or use other tools like profilers or import timings.

License

Distributed under the terms of the MIT license, "pytest-execution-timer" is free and open source software. See LICENSE for more information.

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-execution-timer-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

pytest_execution_timer-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest-execution-timer-0.1.0.tar.gz.

File metadata

  • Download URL: pytest-execution-timer-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Darwin/21.2.0

File hashes

Hashes for pytest-execution-timer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 26b47da77d9e7b31ff5f22e57d636f3b3226dc7144ba524f32283bed08e94dce
MD5 35540366708545679f7985e0766f2605
BLAKE2b-256 05311d652f830e552de22a38d87b758d54ffabcebd29672de29f5424c13c60a4

See more details on using hashes here.

File details

Details for the file pytest_execution_timer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_execution_timer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bde5fe67548eed0151ed4f9583fc2fe51bf066fd73a3a77a37a2951b33265b3c
MD5 1f33bd997f95cedc38ba10329b8db37a
BLAKE2b-256 92f57c9816596e1ee369e3a11e6c376991b5b3f1efe2e4984460a0bf564fe34e

See more details on using hashes here.

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