Skip to main content

A performance plugin for pytest

Project description

pytest-performancetotal

With this plugin for pytest, which complements the playwright-pytest integration, you can seamlessly incorporate performance analysis into your test flows. It’s designed to work with UI interactions, API calls, or a combination of both, providing a straightforward method for measuring response times and pinpointing potential performance issues within your application. By leveraging this data, you can make strategic decisions to optimize and enhance your application’s performance. For insights into the original concept and additional details, refer to the article on the Node.js version of this plugin.

Installation

$ pip install pytest-performancetotal

Usage

To use pytest-performancetotal, simply add the performancetotal fixture to the test method. This will include the performance functionality in your test. No further setup is required. Here's an example:

import pytest

@pytest.mark.parametrize("iteration", [1, 2, 3])
def test_features(performancetotal, iteration):
    performancetotal.sample_start("feature1")
    time.sleep(1)
    performancetotal.sample_end("feature1")
    
    performancetotal.sample_start("feature2")
    time.sleep(0.5)
    performancetotal.sample_end("feature2")

You can also get immediate time span for a single sample inside a test:

feature1_timespan = performancetotal.get_sample_time("feature1")

be aware that get_sample_time returns a single measurement with no statistical analysis.

To use type hints follow this example:

from pytest_performancetotal.performance import Performance

def test_features(performancetotal: Performance, iteration):
            # ... your test code here

Options

To disable appending new results into existing file and start fresh every run use:

pytest --performance-noappend

Getting the results

A new directory named performance_results is created inside your project's root folder. Once all the tests are completed, two files are created inside the performance-results directory: results.json and results.csv. The analyzed data includes average time, standard error of mean (SEM), number of samples, minimum value, maximum value, earliest time, and latest time. The results table is also printed to the terminal log.

Support

For any questions or suggestions contact me at: tzur.paldi@outlook.com

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-performancetotal-0.2.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

pytest_performancetotal-0.2-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest-performancetotal-0.2.tar.gz.

File metadata

  • Download URL: pytest-performancetotal-0.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for pytest-performancetotal-0.2.tar.gz
Algorithm Hash digest
SHA256 aee5df2642bff4b6a175ae205e03c6d74ee0964352d69624e6ccf93ef2bb290a
MD5 7fd1a25d0c94dab5c2529a80e5a0da29
BLAKE2b-256 a08b73a6e41d61fc7cef06a0d55bab381823a768d41fc534e649e427cadd7b54

See more details on using hashes here.

File details

Details for the file pytest_performancetotal-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_performancetotal-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b52da42255b9c08e7ce145d35aa40ff882a0634f5a19edce5d90c74b6564c269
MD5 b6ab2dc86cea2e465b484d5e4865843b
BLAKE2b-256 72b638db18a38bd518e8104bd0dc32fb8705e31dce7e3e413ed4f0bb08bb5c7b

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