Skip to main content

Pytest plugin for analyzing resource usage.

Project description

Pytest-Monitor

pytest-monitor

Documentation Status PyPI version Python versions See Build Status on Circle CI https://img.shields.io/badge/License-MIT-blue.svg

Pytest-monitor is a pytest plugin designed for analyzing resource usage.


Features

  • Analyze your resources consumption through test functions:

    • memory consumption

    • time duration

    • CPU usage

  • Keep a history of your resource consumption measurements.

  • Compare how your code behaves between different environments.

Usage

Simply run pytest as usual: pytest-monitor is active by default as soon as it is installed. After running your first session, a .pymon sqlite database will be accessible in the directory where pytest was run.

Example of information collected for the execution context:

ENV_H

CPU_COUNT

CPU_FREQUENCY_MHZ

CPU_TYPE

CPU_VENDOR

RAM_TOTAL_MB

MACHINE_NODE

MACHINE_TYPE

MACHINE_ARCH

SYSTEM_INFO

PYTHON_INFO

8294b1326007d9f4c8a1680f9590c23d

36

3000

x86_64

Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz

772249

some.host.vm.fr

x86_64

64bit

Linux - 3.10.0-693.el7.x86_64

3.6.8 (default, Jun 28 2019, 11:09:04) n[GCC …

Here is an example of collected data stored in the result database:

RUN_DATE

ENV_H

SCM_ID

ITEM_START_TIME

ITEM

KIND

COMPONENT

TOTAL_TIME

USER_TIME

KERNEL_TIME

CPU_USAGE

MEM_USAGE

2020-02-17T09:11:36.731233

8294b1326007d9f4c8a1680f9590c23d

de23e6bdb987ae21e84e6c7c0357488ee66f2639

2020-02-17T09:11:36.890477

pkg1.test_mod1/test_sleep1

function

None

1.005669

0.54

0.06

0.596618

1.781250

2020-02-17T09:11:36.731233

8294b1326007d9f4c8a1680f9590c23d

de23e6bdb987ae21e84e6c7c0357488ee66f2639

2020-02-17T09:11:39.912029

pkg1.test_mod1/test_heavy[10-10]

function

None

0.029627

0.55

0.08

21.264498

1.781250

2020-02-17T09:11:36.731233

8294b1326007d9f4c8a1680f9590c23d

de23e6bdb987ae21e84e6c7c0357488ee66f2639

2020-02-17T09:11:39.948922

pkg1.test_mod1/test_heavy[100-100]

function

None

0.028262

0.56

0.09

22.998773

1.781250

2020-02-17T09:11:36.731233

8294b1326007d9f4c8a1680f9590c23d

de23e6bdb987ae21e84e6c7c0357488ee66f2639

2020-02-17T09:11:39.983869

pkg1.test_mod1/test_heavy[1000-1000]

function

None

0.030131

0.56

0.10

21.904277

2.132812

2020-02-17T09:11:36.731233

8294b1326007d9f4c8a1680f9590c23d

de23e6bdb987ae21e84e6c7c0357488ee66f2639

2020-02-17T09:11:40.020823

pkg1.test_mod1/test_heavy[10000-10000]

function

None

0.060060

0.57

0.14

11.821601

41.292969

2020-02-17T09:11:36.731233

8294b1326007d9f4c8a1680f9590c23d

de23e6bdb987ae21e84e6c7c0357488ee66f2639

2020-02-17T09:11:40.093490

pkg1.test_mod2/test_sleep_400ms

function

None

0.404860

0.58

0.15

1.803093

2.320312

2020-02-17T09:11:36.731233

8294b1326007d9f4c8a1680f9590c23d

de23e6bdb987ae21e84e6c7c0357488ee66f2639

2020-02-17T09:11:40.510525

pkg2.test_mod_a/test_master_sleep

function

None

5.006039

5.57

0.15

1.142620

2.320312

2020-02-17T09:11:36.731233

8294b1326007d9f4c8a1680f9590c23d

de23e6bdb987ae21e84e6c7c0357488ee66f2639

2020-02-17T09:11:45.530780

pkg3.test_mod_cl/test_method1

function

None

0.030505

5.58

0.16

188.164762

2.320312

2020-02-17T09:11:36.731233

8294b1326007d9f4c8a1680f9590c23d

de23e6bdb987ae21e84e6c7c0357488ee66f2639

2020-02-17T09:11:50.582954

pkg4.test_mod_a/test_force_monitor

function

test

1.005015

11.57

0.17

11.681416

2.320312

Documentation

A full documentation is available.

Installation

You can install pytest-monitor via conda (through the conda-forge channel):

$ conda install pytest-monitor -c https://conda.anaconda.org/conda-forge

Another possibility is to install pytest-monitor via pip from PyPI:

$ pip install pytest-monitor

Requirements

You will need a valid Python 3.5+ interpreter. To get measures, we rely on:

  • psutil to extract CPU usage

  • memory_profiler to collect memory usage

  • and pytest (obviously!)

Contributing

Contributions are very welcome. Tests can be run with tox. Before submitting a pull request, please ensure that:

  • both internal tests and examples are passing.

  • internal tests have been written if necessary.

  • if your contribution provides a new feature, make sure to provide an example and update the documentation accordingly.

License

This code is distributed under the MIT license. pytest-monitor is free, open-source software.

Issues

If you encounter any problem, please file an issue along with a detailed description.

Author

The main author of pytest-monitor is Jean-Sébastien Dieu, who can be reached at jean-sebastien.dieu@cfm.fr.


This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.

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-monitor-1.0.0.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

pytest_monitor-1.0.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest-monitor-1.0.0.tar.gz.

File metadata

  • Download URL: pytest-monitor-1.0.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.8.0.post20190628 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8

File hashes

Hashes for pytest-monitor-1.0.0.tar.gz
Algorithm Hash digest
SHA256 30e73c5831ae13268f6f76dc4352a2c5970d244ce77d5c1b153e3475d1e0fda7
MD5 ef4917178628f478464baad9d6638486
BLAKE2b-256 366b24a08acab47d1ad691a782ff645cf7c61098e5dbeb9690a13480d8e39936

See more details on using hashes here.

File details

Details for the file pytest_monitor-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_monitor-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.8.0.post20190628 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8

File hashes

Hashes for pytest_monitor-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f38c99a1c41edb92904a74d8227c21d8295380a56e1e79e1306a1c140d3c9c7a
MD5 44bd77beab40ac78325908956bc28b99
BLAKE2b-256 4bbc5ec344b8c9da8c007a2b3b2a1df51b54383074c55cad1db8bba4d1d9005d

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