Python module, to inject memory and CPU stress.
Project description
Environments
Activity
Stress Injector
Python module, to inject memory and CPU stress
Insights:
CPU Stress:
- To achieve CPU stress, I have used multiprocess, looped for the # of logical cores, triggering an infinite loop on each core.
- The infinite loop will run for a given # of seconds provided by user.
- Mean-while the
cpu_percent
frompsutil
runs (dedicated thread) in an infinite loop with kill signal set toFalse
calculating the current CPU utilization on each CPU core. - Once the given # of seconds have passed, the
kill_signal
is set toTrue
and some painful steps to gracefully stop themultiprocess
and multi-thread.
Memory Stress:
- In this script, I have used
numpy.random.bytes
which are sampled from uniform distribution. - Generating these random bytes induces a stress on the machine's memory usage.
- I have then used
getrusage
(get resource usage) forSELF
to get the memory consumed only by the current script. - The
size_converter
converts the bytes from resource usage to a human understandable format.
Coding Standards:
Docstring format: Google
Styling conventions: PEP 8
Clean code with pre-commit hooks: flake8
and
isort
Pre-Commit
pre-commit
will run flake8
and isort
to ensure proper coding standards along with docs_generator
to update the runbook
pre-commit run --all-files
Runbook:
https://thevickypedia.github.io/stress_injector/
Generated using
sphinx-autogen
License & copyright
© Vignesh Sivanandha Rao
Licensed under the MIT License
Change Log
0.0.1 (08/04/2021)
- Onboard stress-injector to pypi
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
stress-injector-0.0.1.tar.gz
(6.6 kB
view hashes)
Built Distribution
Close
Hashes for stress_injector-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e51aab33340e13f0c0a3f7e999d0a543cb01b23dec1b676b1608391d2df88c2 |
|
MD5 | 31e8d20a0dcdf989f1b5306b4da1f4b5 |
|
BLAKE2b-256 | 335e8b60ef22c530d407baed7b9afc70e9e8b770869bca984ef79e53762464fb |