Created
January 8, 2026 16:03
-
-
Save craigderington/d2eb43115ad694abcf07ff686431cc39 to your computer and use it in GitHub Desktop.
benchmark.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # System Benchmark Suite v2 | |
| # Optimized for NUC7i5BNH vs Ryzen 7 6800H comparison | |
| set -e | |
| RESULTS_DIR="$(pwd)/benchmark_$(hostname)_$(date +%Y%m%d_%H%M%S)" | |
| mkdir -p "$RESULTS_DIR" | |
| log() { | |
| echo "$1" | tee -a "$RESULTS_DIR/full_log.txt" | |
| } | |
| log "==========================================" | |
| log "System Benchmark Suite" | |
| log "Host: $(hostname)" | |
| log "Date: $(date)" | |
| log "==========================================" | |
| # System info | |
| log "" | |
| log "=== SYSTEM INFO ===" | |
| CPU_MODEL=$(lscpu | grep 'Model name' | cut -d: -f2 | xargs) | |
| CORES=$(nproc) | |
| RAM=$(free -h | awk '/^Mem:/ {print $2}') | |
| KERNEL=$(uname -r) | |
| log "CPU: $CPU_MODEL" | |
| log "Cores/Threads: $CORES" | |
| log "RAM: $RAM" | |
| log "Kernel: $KERNEL" | |
| # Memory details | |
| log "" | |
| log "Memory Details:" | |
| sudo dmidecode -t memory 2>/dev/null | grep -E "Type:|Speed:|Size:" | head -8 | while read line; do log " $line"; done || log " (requires root for dmidecode)" | |
| # Create summary file | |
| cat > "$RESULTS_DIR/SUMMARY.csv" << EOF | |
| test,metric,value,unit | |
| system,cpu,$CPU_MODEL, | |
| system,cores,$CORES, | |
| system,ram,$RAM, | |
| EOF | |
| # ------------------------------ | |
| # 1. CPU - Single Thread | |
| # ------------------------------ | |
| log "" | |
| log "=== CPU: SINGLE-THREADED ===" | |
| RESULT=$(sysbench cpu --cpu-max-prime=20000 --threads=1 run 2>&1) | |
| echo "$RESULT" > "$RESULTS_DIR/cpu_single.txt" | |
| CPU_SINGLE=$(echo "$RESULT" | grep "events per second" | awk '{print $4}') | |
| log "Events/sec: $CPU_SINGLE" | |
| echo "cpu_single,events_per_sec,$CPU_SINGLE," >> "$RESULTS_DIR/SUMMARY.csv" | |
| # ------------------------------ | |
| # 2. CPU - Multi Thread | |
| # ------------------------------ | |
| log "" | |
| log "=== CPU: MULTI-THREADED ($CORES threads) ===" | |
| RESULT=$(sysbench cpu --cpu-max-prime=20000 --threads=$CORES run 2>&1) | |
| echo "$RESULT" > "$RESULTS_DIR/cpu_multi.txt" | |
| CPU_MULTI=$(echo "$RESULT" | grep "events per second" | awk '{print $4}') | |
| log "Events/sec: $CPU_MULTI" | |
| echo "cpu_multi,events_per_sec,$CPU_MULTI," >> "$RESULTS_DIR/SUMMARY.csv" | |
| # ------------------------------ | |
| # 3. Memory Bandwidth | |
| # ------------------------------ | |
| log "" | |
| log "=== MEMORY BANDWIDTH ===" | |
| RESULT=$(sysbench memory --memory-block-size=1M --memory-total-size=10G --memory-oper=write --threads=1 run 2>&1) | |
| echo "$RESULT" > "$RESULTS_DIR/mem_write_single.txt" | |
| MEM_WRITE=$(echo "$RESULT" | grep "transferred" | grep -oP '[\d.]+(?= MiB/sec)') | |
| log "Write (1 thread): $MEM_WRITE MiB/sec" | |
| echo "memory_write_1t,bandwidth,$MEM_WRITE,MiB/sec" >> "$RESULTS_DIR/SUMMARY.csv" | |
| RESULT=$(sysbench memory --memory-block-size=1M --memory-total-size=20G --memory-oper=write --threads=$CORES run 2>&1) | |
| echo "$RESULT" > "$RESULTS_DIR/mem_write_multi.txt" | |
| MEM_WRITE_MT=$(echo "$RESULT" | grep "transferred" | grep -oP '[\d.]+(?= MiB/sec)') | |
| log "Write ($CORES threads): $MEM_WRITE_MT MiB/sec" | |
| echo "memory_write_mt,bandwidth,$MEM_WRITE_MT,MiB/sec" >> "$RESULTS_DIR/SUMMARY.csv" | |
| RESULT=$(sysbench memory --memory-block-size=1M --memory-total-size=10G --memory-oper=read --threads=$CORES run 2>&1) | |
| echo "$RESULT" > "$RESULTS_DIR/mem_read_multi.txt" | |
| MEM_READ=$(echo "$RESULT" | grep "transferred" | grep -oP '[\d.]+(?= MiB/sec)') | |
| log "Read ($CORES threads): $MEM_READ MiB/sec" | |
| echo "memory_read_mt,bandwidth,$MEM_READ,MiB/sec" >> "$RESULTS_DIR/SUMMARY.csv" | |
| # ------------------------------ | |
| # 4. Disk I/O | |
| # ------------------------------ | |
| log "" | |
| log "=== DISK I/O ===" | |
| # Sequential write | |
| RESULT=$(dd if=/dev/zero of="$RESULTS_DIR/testfile" bs=1M count=1024 conv=fdatasync 2>&1) | |
| echo "$RESULT" > "$RESULTS_DIR/disk_seq_write.txt" | |
| DISK_WRITE=$(echo "$RESULT" | grep -oP '[\d.]+ [MG]B/s' | tail -1) | |
| log "Sequential Write: $DISK_WRITE" | |
| rm -f "$RESULTS_DIR/testfile" | |
| # Random I/O with sysbench | |
| log "Preparing random I/O test..." | |
| ORIG_DIR="$(pwd)" | |
| cd "$RESULTS_DIR" | |
| sysbench fileio --file-total-size=2G prepare > /dev/null 2>&1 | |
| RESULT=$(sysbench fileio --file-total-size=2G --file-test-mode=rndrw --time=30 --threads=4 run 2>&1) | |
| echo "$RESULT" > disk_random.txt | |
| DISK_IOPS=$(echo "$RESULT" | grep -E "reads/s:|writes/s:" | head -1 | grep -oP '[\d.]+') | |
| DISK_LAT=$(echo "$RESULT" | grep "avg:" | tail -1 | awk '{print $2}') | |
| log "Random IOPS: $DISK_IOPS" | |
| log "Avg Latency: $DISK_LAT ms" | |
| sysbench fileio --file-total-size=2G cleanup > /dev/null 2>&1 | |
| cd "$ORIG_DIR" | |
| # ------------------------------ | |
| # 5. 7-Zip (Best overall benchmark) | |
| # ------------------------------ | |
| log "" | |
| log "=== 7-ZIP BENCHMARK ===" | |
| if command -v 7z &> /dev/null; then | |
| RESULT=$(7z b 2>&1) | |
| echo "$RESULT" > "$RESULTS_DIR/7zip.txt" | |
| MIPS_COMP=$(echo "$RESULT" | grep "^Tot:" | awk '{print $4}') | |
| MIPS_DECOMP=$(echo "$RESULT" | grep "^Tot:" | awk '{print $7}') | |
| log "Compression: $MIPS_COMP MIPS" | |
| log "Decompression: $MIPS_DECOMP MIPS" | |
| echo "7zip,compress_mips,$MIPS_COMP,MIPS" >> "$RESULTS_DIR/SUMMARY.csv" | |
| echo "7zip,decompress_mips,$MIPS_DECOMP,MIPS" >> "$RESULTS_DIR/SUMMARY.csv" | |
| else | |
| log "7z not installed, skipping" | |
| fi | |
| # ------------------------------ | |
| # 6. OpenSSL (AES-NI test) | |
| # ------------------------------ | |
| log "" | |
| log "=== OPENSSL CRYPTO ===" | |
| RESULT=$(openssl speed -seconds 5 -evp aes-256-gcm 2>&1) | |
| echo "$RESULT" > "$RESULTS_DIR/openssl.txt" | |
| AES_SPEED=$(echo "$RESULT" | grep "aes-256-gcm" | awk '{print $7}') | |
| log "AES-256-GCM: $AES_SPEED bytes/sec" | |
| # ------------------------------ | |
| # 7. Stress Test (sustained perf) | |
| # ------------------------------ | |
| log "" | |
| log "=== SUSTAINED LOAD (60 sec) ===" | |
| log "Running sustained CPU test..." | |
| RESULT=$(sysbench cpu --cpu-max-prime=50000 --threads=$CORES --time=60 run 2>&1) | |
| echo "$RESULT" > "$RESULTS_DIR/sustained.txt" | |
| SUSTAINED=$(echo "$RESULT" | grep "events per second" | awk '{print $4}') | |
| log "Sustained events/sec: $SUSTAINED" | |
| echo "cpu_sustained_60s,events_per_sec,$SUSTAINED," >> "$RESULTS_DIR/SUMMARY.csv" | |
| # ------------------------------ | |
| # Summary | |
| # ------------------------------ | |
| log "" | |
| log "==========================================" | |
| log "BENCHMARK COMPLETE" | |
| log "==========================================" | |
| log "" | |
| log "Results directory: $RESULTS_DIR" | |
| log "" | |
| log "=== QUICK SUMMARY ===" | |
| log "CPU Single: $CPU_SINGLE events/sec" | |
| log "CPU Multi: $CPU_MULTI events/sec" | |
| log "Memory Write: $MEM_WRITE_MT MiB/sec" | |
| log "7-Zip: $MIPS_COMP / $MIPS_DECOMP MIPS" | |
| log "" | |
| cat "$RESULTS_DIR/SUMMARY.csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment