Python module, to inject memory and CPU stress.
Project description
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
0.0.2 (08/04/2021)
- Update docs
- Change module name
- Fix broken references
0.0.3 (08/04/2021)
- Roll back module name
- Update badges in README.md
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.3.tar.gz
(6.7 kB
view hashes)
Built Distribution
Close
Hashes for stress_injector-0.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b58e182578a8ee9297f1f08e015640f79dd7847cd33f41c07b8cb6cb7065281 |
|
MD5 | 231b02d4136ebd6adc4289bd62114d9e |
|
BLAKE2b-256 | 7d73fbf286e1eb1c846a6a70e63e7bbf6124acbf899c1ee8dfed4d53a6bc1e37 |