Ir al contenido

TestPcForProgramers

Python 3BashNumbaNumPymatplotlibmultiprocessingMIT

GitHub: stevenvo780/TestPcForProgramers


TestPcForProgramers is a hardware benchmark suite aimed at developers who want to stress-test and characterise their machines using workloads that reflect real programming tasks: scientific simulation, matrix multiplication, memory throughput, disk I/O, and kernel compilation.

The suite has two layers:

Layer What it is
N-body gravitational simulator (nbody_simulation.py) The main CPU stress tool: O(n²) pairwise gravity simulation with Numba JIT, Python multiprocessing, and NumPy BLAS. Real-time matplotlib animation.
Benchmark suite (run_bench_suite.sh + 4 scripts) Four focused micro-benchmarks with consistent JSON output and history files for longitudinal comparison.

The flagship tool simulates N-body gravitational interactions under full pairwise O(n²) forces. It is designed to load every CPU core and measure sustained floating-point throughput under a realistic scientific workload.

Parallelisation options (select at runtime):

Mode Implementation Typical speedup
Numba JIT @jit(nopython=True, parallel=True) — auto-parallelises inner loop 3–8× vs pure Python
Python multiprocessing multiprocessing.Pool — splits body chunks across workers scales with core count
NumPy / BLAS vectorised broadcasting — fast on systems with tuned BLAS good single-core baseline

Integrators:

Integrator Use case
Runge-Kutta 4 Higher precision, lower energy drift
Euler Faster iteration, useful for pure throughput benchmarking

Built-in scenarios:

Scenario Bodies Purpose
solar ~25 Quick sanity check; short run time
galaxy 200–500 Sustained mid-tier load
benchmark 1000+ Full CPU stress; measures peak parallel throughput

Real-time visualisation: matplotlib animation with movement trails. Disable with --no-viz to maximise CPU allocation to simulation.


Four focused scripts invoked by run_bench_suite.sh. Each prints a BENCH_JSON: {...} line on stdout and appends results to a JSON history file, enabling longitudinal tracking across hardware changes, kernel updates, or compiler upgrades.

Script What it measures History file
kernel-build-bench.sh Linux kernel compile time (wall clock, user, sys) kernel-build-history.json
cpu_matmul_bench.py GEMM peak throughput in GFLOPS (NumPy) cpu-matmul-history.json
memory_bandwidth_bench.py Memory-to-memory copy bandwidth in GB/s memory-bandwidth-history.json
disk_io_bench.py Sequential write + read throughput in MiB/s disk-io-history.json

Run all four in sequence:

Ventana de terminal
bash run_bench_suite.sh

Ventana de terminal
git clone https://github.com/stevenvo780/TestPcForProgramers.git
cd TestPcForProgramers
pip install -r requirements.txt
# requirements: numpy>=1.21.0, matplotlib>=3.5.0, psutil>=5.8.0, numba>=0.56.0
python3 nbody_simulation.py

N-body simulator flags:

Ventana de terminal
python3 nbody_simulation.py --scenario galaxy --method numba --integrator rk4
python3 nbody_simulation.py --scenario benchmark --method multiprocessing --no-viz

Individual suite scripts:

Ventana de terminal
python3 cpu_matmul_bench.py # prints GFLOPS + appends to cpu-matmul-history.json
python3 memory_bandwidth_bench.py # prints GB/s + appends to memory-bandwidth-history.json
python3 disk_io_bench.py # prints MiB/s + appends to disk-io-history.json
bash kernel-build-bench.sh # prints seconds + appends to kernel-build-history.json

Layer Technology
N-body simulation Python 3, Numba JIT (@jit nopython+parallel), NumPy BLAS, multiprocessing.Pool
Integration Runge-Kutta 4 / Euler
Visualisation matplotlib (real-time animation with trails)
System monitoring psutil (CPU affinity, core count)
GEMM benchmark NumPy (BLAS-backed matrix multiply)
Memory benchmark NumPy array copy, timed with time.perf_counter
Disk benchmark Python stdlib os + time, sequential file I/O
Kernel benchmark Bash + make -j$(nproc)
History output JSON (one record per run, append-only)