Skip to main content

CPU load generator

Project description

CPU Load Generator

This package allows to generate a fixed CPU load for a finite time period. The script takes in input the desired CPU load, the duration of the experiment and the CPU core or all cores on which the load has to be generated.

Python versions This master branch refers to Python versions 3.x

Dependencies Installment of psutil is required (it is already set as dependency in the setup.py)

Install psutil:

pip install psutil

Other dependencies for unit tests and linters:

pip install mock pytest flake8 tox

Usage To generate 20% of load on core 0 for 20 seconds run:

python -m cpu_load_generator -l 0.2 -d 20 -c 0

To generate 50% of load on all logical cores for 20 seconds run:

python -m cpu_load_generator -l 0.5 -d 20 -c -1

There is an option to run CPU load based on profile file. An exemplary profile is under load_profiles/default_profile.json. In order to run generator based on a profile issue the following command:

python -m cpu_load_generator -p <path_to_profile_json>

To use the package features from python code:

Install the package from PyPi by issuing the following command:

python -m pip instal cpu-load-generator

To use its features from your code:

from cpu_load_generator import load_single_core, load_all_cores, from_profile

load_single_core(core_num=0, duration_s=20, target_load=0.4)  # generate load on single core (0)
load_all_cores(duration_s=30, target_load=0.2)  # generates load on all cores
from_profile(path_to_profile_json=r"c:\profiles\profile1.json")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cpu-load-generator-1.2.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

cpu_load_generator-1.2.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file cpu-load-generator-1.2.0.tar.gz.

File metadata

  • Download URL: cpu-load-generator-1.2.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for cpu-load-generator-1.2.0.tar.gz
Algorithm Hash digest
SHA256 41586edd59e5d9e75a39a0c8c86e8baa8eac0550dc4dab8c0bef9eeac328b8af
MD5 5038c2ddf4825115fa70e32119d077d8
BLAKE2b-256 27360c126a072884ebbeced8709b05f314af4243d73149a17e919bf4c881cba2

See more details on using hashes here.

File details

Details for the file cpu_load_generator-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: cpu_load_generator-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for cpu_load_generator-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4c64b9eb8ae1044ac3c775541600a9d07c31a146395c89d8c313194a460cca1
MD5 37f80c70f8ff5bec3846cdf1919e3e95
BLAKE2b-256 ec57958a1792efbb8a223702de0b61d088c7a64cfcc134a7bf2e0a0be7ab6bf9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page