Pytest plugin to track and report system usage statistics
Project description
What is Pytest System Statistics
It’s a pytest plugin, extracted from pytest-salt-factories, which tracks the test suite CPU and memory usage and, optionally, includes a report section including that data, for example:
test_proc_sys_stats.py::test_one PASSED [100%]
----------------------------------- Processes Statistics ------------------------------------
.......... System - CPU: 17.80 % MEM: 29.70 % (Virtual Memory) SWAP: 12.80 %
.. Test Suite Run - CPU: 0.00 % MEM: 0.05 % (RSS) MEM SUM: 0.09 % (RSS) CHILD PROCS: 2
...... FooProcess - CPU: 0.00 % MEM: 0.02 % (RSS) MEM SUM: 0.03 % (RSS) CHILD PROCS: 1
==================================== 1 passed in 0.34s ======================================
Install
Installing Pytest System Statistics is as simple as:
python -m pip install pytest-system-statistics
Usage
Controlling the behaviour of the plugin is made through flags which are passed to pytest.
--sys-stats Print System CPU and MEM statistics after each test execution.
--no-sys-stats Do not print System CPU and MEM statistics after each test execution.
--sys-stats-no-children Don't include child processes memory statistics.
--sys-stats-uss-mem Use the USS("Unique Set Size", memory unique to a process which
would be freed if the process was terminated) memory instead which
is more expensive to calculate.
Tracking Additional Processes
To include additional processes to track and report statistics against, simply add it to the session scoped stats_processes fixture, for example:
@pytest.fixture
def my_server_process(stats_processes):
proc = subprocess.Popen(...)
stats_processes.add("MyServerProcess", proc.pid)
try:
yield proc
finally:
stats_processes.remove("MyServerProcess")
Contributing
The pytest-system-statistics project team welcomes contributions from the community. For more detailed information, refer to CONTRIBUTING.
Documentation
The full documentation can be seen here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest-system-statistics-1.0.2.tar.gz
.
File metadata
- Download URL: pytest-system-statistics-1.0.2.tar.gz
- Upload date:
- Size: 56.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 059b739e3f4e288cd1e4dbe5785e077ee89df26f64e6c5164e9bb5d6657a4a71 |
|
MD5 | 5da573a2df864f2ecb28df978d1c33a1 |
|
BLAKE2b-256 | f31b1fb514da7c049915e1d8dd843fee663a400b8db9c8a39d5fe7ca5a6e99c7 |
File details
Details for the file pytest_system_statistics-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: pytest_system_statistics-1.0.2-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54abc7335d60a89ef0658ee233790d9ae65aed518233df50b0530244369b06ec |
|
MD5 | 99724590b481b2d624468e29cf792194 |
|
BLAKE2b-256 | d8764ab17888a165f5493aae50ebfb5a99eeb4a5592cddf55c67ed6f4d072bae |