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.
Pypi Module
https://pypi.org/project/gmail-connector/
Usage
pip install stress-injector
from stressinjector.cpu import cpu_stress
cpu_stress()
from stressinjector.memory import memory_stress
memory_stress()
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
0.0.4 (08/04/2021)
- Mark methods as internal
- Update dependencies and readme
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.4.tar.gz
(7.2 kB
view hashes)
Built Distribution
Close
Hashes for stress_injector-0.0.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf12c67a8d08842f3e418ab759a052976221558a2a5c7ea2f56f55d290f4b0b4 |
|
MD5 | dfa5c9a51754b1e91b1a14e702bc228a |
|
BLAKE2b-256 | 5c81e5570eb699b76cdb3ba473bb39efa1ec4a5fca072d470420ff9a72ee7c0b |