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.1.tar.gz
.
File metadata
- Download URL: pytest-system-statistics-1.0.1.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b900055d84170eb7309e207b560b4b58d503f7572151c58836db25707284666b |
|
MD5 | 4b025e1014f3dd04eb2529475907d6a2 |
|
BLAKE2b-256 | 6adbe6eff3a6fed5de2c3020855016ec21c42c1d7aaa127bd3f9907b4c7aab4d |
File details
Details for the file pytest_system_statistics-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: pytest_system_statistics-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bd8d6985d963509fba4fd4f0c5847b5c3ec24ecf7047480bd6686b5fadc65d6 |
|
MD5 | 3b340843f343d73a09481b5d97378b84 |
|
BLAKE2b-256 | 3755956fbd20d795a200835aba05e72600b0b97bdaea16ae393c8989c2cd1bc0 |