An open API service indexing awesome lists of open source software.

https://github.com/laspavel/cpu_load


https://github.com/laspavel/cpu_load

cpu-load load-testing python python3

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

          

# CPU Load Generator

![Python](https://img.shields.io/badge/python-3.6+-blue.svg)
![License](https://img.shields.io/badge/license-MIT-green)

A cross-platform CPU load generator for benchmarking and testing
Supports configurable utilization, duration, and number of cores.

## ๐Ÿ“Œ Features

* Generate custom CPU load (1%โ€“100%)
* Control test duration (in seconds)
* Load specific number of CPU cores
* Clean interruption handling (Ctrl+C)

## โš™๏ธ Requirements

- Python 3.6 or newer
- Linux, Windows

## ๐Ÿš€ Installation & Usage

```bash
git clone https://github.com/laspavel/cpu_load.git
cd cpu_load
chmod +x cpu_load.py
./cpu_load.py [-i INTERVAL] [-u UTILIZATION] [-c CPUS] [-v]
```

Python dependencies are only from the standard library, no installation of packages is required.

Parameters:

| Parameters | Description | Default |
| ------------------ | ----------------------------------------------------- | --------------------|
| -i, --interval | Duration in seconds to run the test | 30 |
| -u, --utilization | CPU load percentage per core | 50 |
| -c, --cpus | Number of CPU cores to load (max = physical cores) | all available cores |
| -v, --version | Show program version and exit | |

## ๐Ÿงฉ Example Usage

```bash
./load_cpu.py -i 60 -u 90 -c 2 # Run for 60 seconds at 90% load on 2 CPU cores
```

## ๐Ÿ›  Build Standalone Binary

```bash
./build.sh
```

## ๐Ÿงช Testing Locally

If you prefer to run the load script directly on your host system:โ€‹

```bash
chmod +x load_cpu.sh
./load_cpu.py
```

โš ๏ธ Make sure Python 3 is installed and executable is marked with `chmod +x`.

## ๐Ÿ“ Project Structure
```plaintext
cpu_load/
โ”œโ”€โ”€ cron/ # Example cron tasks for automated stress tests
โ”œโ”€โ”€ src/ # Source code for load generation
โ”œโ”€โ”€ build.sh # Script to build binary file
โ”œโ”€โ”€ Dockerfile.build # Docker image for build binary file
โ”œโ”€โ”€ LICENSE # MIT License
โ””โ”€โ”€ README.md # Project documentation
```

## ๐Ÿ“„ License
MIT License.โ€‹

## ๐Ÿค Contributions

Suggestions and improvements are welcome! Feel free to open an issue or submit a pull request.

## ๐Ÿ“ฌ Contact

Author: [laspavel](https://github.com/laspavel)

Feel free to reach out with questions or ideas.

---