Ir al contenido

TestPcForProgramers

Python 3 Bash Numba NumPy matplotlib multiprocessing MIT

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:

LayerWhat 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):

ModeImplementationTypical speedup
Numba JIT@jit(nopython=True, parallel=True) — auto-parallelises inner loop3–8× vs pure Python
Python multiprocessingmultiprocessing.Pool — splits body chunks across workersscales with core count
NumPy / BLASvectorised broadcasting — fast on systems with tuned BLASgood single-core baseline

Integrators:

IntegratorUse case
Runge-Kutta 4Higher precision, lower energy drift
EulerFaster iteration, useful for pure throughput benchmarking

Built-in scenarios:

ScenarioBodiesPurpose
solar~25Quick sanity check; short run time
galaxy200–500Sustained mid-tier load
benchmark1000+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.

ScriptWhat it measuresHistory file
kernel-build-bench.shLinux kernel compile time (wall clock, user, sys)kernel-build-history.json
cpu_matmul_bench.pyGEMM peak throughput in GFLOPS (NumPy)cpu-matmul-history.json
memory_bandwidth_bench.pyMemory-to-memory copy bandwidth in GB/smemory-bandwidth-history.json
disk_io_bench.pySequential write + read throughput in MiB/sdisk-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

LayerTechnology
N-body simulationPython 3, Numba JIT (@jit nopython+parallel), NumPy BLAS, multiprocessing.Pool
IntegrationRunge-Kutta 4 / Euler
Visualisationmatplotlib (real-time animation with trails)
System monitoringpsutil (CPU affinity, core count)
GEMM benchmarkNumPy (BLAS-backed matrix multiply)
Memory benchmarkNumPy array copy, timed with time.perf_counter
Disk benchmarkPython stdlib os + time, sequential file I/O
Kernel benchmarkBash + make -j$(nproc)
History outputJSON (one record per run, append-only)