diff --git a/benchmark.sh.ORIG b/benchmark.sh.VJR.FULL index a5c3e4f..8c8f29a 100755 --- a/benchmark.sh.ORIG +++ b/benchmark.sh.VJR.FULL @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# ▌ benchmark — a modern VPS benchmark +# ▌ benchmark — a modern Unix benchmark # ▌ # ▌ System info · CPU · Memory · Disk · Network — zero dependencies, one file. # ▌ Inspired by yabs.sh (Mason Rowe) and bench.sh (Teddysun). @@ -440,7 +440,7 @@ banner() { else mark="$C_ACCENT$word" fi - local tagline="the modern VPS benchmark" + local tagline="the modern Unix benchmark" local ver="v$BENCHMARK_VERSION" local pad=$((TERM_WIDTH - 4 - ${#word} - 3 - ${#tagline} - ${#ver} - 2)) ((pad < 1)) && pad=1 @@ -450,6 +450,7 @@ banner() { # context strip: what we're running on, at a glance local ctx="${R_OS:-$(uname -s)}" [[ -n "${R_CPU_CORES:-}" ]] && ctx+=" $G_SEP ${R_CPU_CORES} cores" + [[ -n "${R_CPU_THREADS:-}" ]] && ctx+=" $G_SEP ${R_CPU_THREADS} threads" [[ -n "${R_ARCH:-}" ]] && ctx+=" $G_SEP ${R_ARCH}" ctx+=" $G_SEP $(date '+%Y-%m-%d %H:%M %Z')" printf ' %s%s%s\n\n' "$C_MUTE" "$ctx" "$RST" @@ -578,6 +579,7 @@ $SKIP_GB || STEP_TOTAL=$((STEP_TOTAL + 1)) R_CPU_MODEL="" R_CPU_CORES="" R_CPU_FREQ="" R_RAM="" R_DISK="" R_OS="" R_KERNEL="" R_VIRT="" R_ARCH="" R_AES=false R_UPTIME="" R_LOAD="" R_CPU_ISA="" R_RAM_MB=0 +R_CPU_THREADS="" # turn a space-separated CPU flag list into a readable ISA-extension string, # best first. Covers x86 (avx512/avx2/…) and ARM (sve/asimd/…). @@ -620,7 +622,8 @@ collect_sysinfo() { R_CPU_MODEL=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo 2>/dev/null | sed 's/^[ \t]*//') [[ -z "$R_CPU_MODEL" ]] && exists lscpu && \ R_CPU_MODEL=$(lscpu | awk -F: '/Model name/ {print $2; exit}' | sed 's/^[ \t]*//') - R_CPU_CORES=$(nproc 2>/dev/null || grep -c ^processor /proc/cpuinfo 2>/dev/null) + R_CPU_CORES=$(lscpu -p=core,socket 2>/dev/null | grep -v '^#' | sort -u | wc -l) + R_CPU_THREADS=$(lscpu -p=cpu 2>/dev/null | grep -v '^#' | wc -l) R_CPU_FREQ=$(awk -F'[ :]+' '/cpu MHz/ {printf "%.0f", $4; exit}' /proc/cpuinfo 2>/dev/null) if [[ -z "$R_CPU_FREQ" || "$R_CPU_FREQ" == "0" ]] && exists lscpu; then R_CPU_FREQ=$(lscpu 2>/dev/null | awk -F: '/CPU max MHz/ {gsub(/ /,"",$2); printf "%.0f", $2; exit}') @@ -671,9 +674,11 @@ print_sysinfo() { local cpu_line="$C_TEXT$R_CPU_MODEL$RST" row "CPU" "$cpu_line" local core_line="$C_TEXT$R_CPU_CORES cores$RST" + local thread_line="$C_TEXT$R_CPU_THREADS threads$RST" [[ -n "$R_CPU_FREQ" ]] && core_line+=" $C_MUTE@ $R_CPU_FREQ$RST" if $R_AES; then core_line+=" $(ok) ${C_MUTE}AES-NI$RST"; else core_line+=" $(bad) ${C_MUTE}AES-NI$RST"; fi row "Cores" "$core_line" + row "Threads" "$thread_line" [[ -n "$R_CPU_ISA" ]] && row "Instructions" "$C_TEXT$R_CPU_ISA$RST" row "Memory" "$C_TEXT$R_RAM$RST" row "Disk" "$C_TEXT$R_DISK$RST" @@ -877,7 +882,7 @@ probe_cpu_val() { # probe_cpu_val → CPUN if threads>1 else CP # openssl fallback: in-process sha256 (SHA-NI where present). Crypto throughput, # not general CPU — only used when no compiler is available. TASKSET=() -command -v taskset >/dev/null 2>&1 && TASKSET=(taskset -c 0) +command -v taskset >/dev/null 2>&1 && taskset -c 0 true >/dev/null 2>&1 && TASKSET=(taskset -c 0) openssl_sha_mbps() { # openssl_sha_mbps → integer MB/s local secs=$1 multi=$2 pin=$3 @@ -895,7 +900,7 @@ openssl_sha_mbps() { # openssl_sha_mbps → integer MB/s } bench_cpu() { - local cores=${R_CPU_CORES:-1} + local cores=${R_CPU_THREADS:-1} local secs=1 bursts=10 $QUICK && bursts=5 @@ -1933,6 +1938,7 @@ emit_json() { "system": { "cpu": "$(json_escape "$R_CPU_MODEL")", "cores": ${R_CPU_CORES:-null}, + "threads": ${R_CPU_THREADS:-null}, "os": "$(json_escape "$R_OS")", "kernel": "$(json_escape "$R_KERNEL")", "arch": "$(json_escape "$R_ARCH")",