Skip to content

Instantly share code, notes, and snippets.

@plasmadice
Last active November 13, 2025 16:45
Show Gist options
  • Select an option

  • Save plasmadice/7f82572549fbc08a34c75e12cec7f02d to your computer and use it in GitHub Desktop.

Select an option

Save plasmadice/7f82572549fbc08a34c75e12cec7f02d to your computer and use it in GitHub Desktop.
Docker disk and network benchmark + Geekbench 6
#!/bin/bash
# Minimal YABS benchmark - copy-paste this command to run on any Docker instance
# Includes disk, Geekbench, and network tests
docker run --rm -it debian:stable bash -c "
apt-get update -qq &&
apt-get install -y -qq curl jq sed bc &&
echo 'Running YABS benchmark...' &&
OUTPUT=\$(curl -sL https://yabs.sh | bash -s -- -rj -w /tmp/results.json 2>&1) &&
echo \"\$OUTPUT\" &&
echo '' &&
echo 'Benchmark completed. Extracting results...' &&
echo '' &&
# Try to get JSON from file first, then from stdout if file is invalid
if [ -f /tmp/results.json ]; then
# Fix invalid JSON by replacing empty values with null
sed -i 's/\"ram\":,/\"ram\":null,/g; s/\"swap\":,/\"swap\":null,/g; s/\"disk\":,/\"disk\":null,/g' /tmp/results.json 2>/dev/null || true
JSON_FILE=/tmp/results.json
else
# Extract JSON from stdout (handle multi-line JSON)
echo \"\$OUTPUT\" | grep -o '{.*}' | tail -1 | sed 's/\"ram\":,/\"ram\":null,/g; s/\"swap\":,/\"swap\":null,/g; s/\"disk\":,/\"disk\":null,/g' > /tmp/results.json 2>/dev/null || true
JSON_FILE=/tmp/results.json
fi &&
# Always fix JSON even if file exists (in case it wasn't fixed before)
if [ -f \"\$JSON_FILE\" ]; then
sed -i 's/\"ram\":,/\"ram\":null,/g; s/\"swap\":,/\"swap\":null,/g; s/\"disk\":,/\"disk\":null,/g' \"\$JSON_FILE\" 2>/dev/null || true
fi &&
# Format number with 1 decimal place (rounds to nearest 0.1)
format_num() {
echo \"scale=1; \$1 / 1\" | bc
}
# Format IOPS with K suffix for thousands
format_iops() {
if [ \$(echo \"\$1 >= 1000\" | bc) -eq 1 ]; then
echo \"scale=1; \$1 / 1000\" | bc | sed 's/^\./0./' | sed 's/$/K/'
else
echo \"\$1\" | bc
fi
}
echo '## 📊 Disk Transfer Test Results' &&
if [ -f \"\$JSON_FILE\" ] && jq -e '.fio != null and (.fio | length) > 0' \"\$JSON_FILE\" >/dev/null 2>&1; then
jq -r '.fio[] | \"\(.bs)|\(.speed_r / 1024)|\(.speed_w / 1024)|\(.speed_rw / 1024)|\(.iops_r)|\(.iops_w)\"' \"\$JSON_FILE\" | while IFS='|' read -r bs read write rw riops wiops; do
READ_FMT=\$(format_num \"\$read\")
WRITE_FMT=\$(format_num \"\$write\")
RW_FMT=\$(format_num \"\$rw\")
RIOPS_FMT=\$(format_iops \"\$riops\")
WIOPS_FMT=\$(format_iops \"\$wiops\")
echo \"### \${bs} Block Size\" &&
echo \"- **Read:** \${READ_FMT} MB/s (\${RIOPS_FMT} IOPS)\" &&
echo \"- **Write:** \${WRITE_FMT} MB/s (\${WIOPS_FMT} IOPS)\" &&
echo \"- **R/W Combined:** \${RW_FMT} MB/s\" &&
echo ''
done
else
echo '⚠️ Disk test results not available'
fi &&
echo '## ⚡ Geekbench 6 Results' &&
echo '' &&
if [ -f \"\$JSON_FILE\" ] && jq -e '.geekbench != null and (.geekbench | length) > 0' \"\$JSON_FILE\" >/dev/null 2>&1; then
SINGLE=\$(jq -r '.geekbench[0].single' \"\$JSON_FILE\" 2>/dev/null)
MULTI=\$(jq -r '.geekbench[0].multi' \"\$JSON_FILE\" 2>/dev/null)
URL=\$(jq -r '.geekbench[0].url' \"\$JSON_FILE\" 2>/dev/null)
if [ \"\$SINGLE\" != \"null\" ] && [ ! -z \"\$SINGLE\" ]; then
echo \"- **Single Core Score:** \${SINGLE}\" &&
echo \"- **Multi Core Score:** \${MULTI}\" &&
if [ \"\$URL\" != \"null\" ] && [ ! -z \"\$URL\" ]; then
echo \"- **Full Results:** [View on Geekbench](\${URL})\"
fi
else
echo 'Geekbench results not available'
fi
else
echo 'Geekbench results not available'
fi &&
echo '' &&
echo '## 🌐 Network Speed Test Results' &&
echo '' &&
if [ -f \"\$JSON_FILE\" ] && jq -e '.iperf != null and (.iperf | length) > 0' \"\$JSON_FILE\" >/dev/null 2>&1; then
COUNT=\$(jq '.iperf | length' \"\$JSON_FILE\" 2>/dev/null || echo \"0\")
if [ \"\$COUNT\" -gt 0 ]; then
SEND_TOTAL=\$(jq '[.iperf[].send | match(\"[0-9]+\") | .string | tonumber] | add' \"\$JSON_FILE\" 2>/dev/null || echo \"0\")
RECV_TOTAL=\$(jq '[.iperf[].recv | match(\"[0-9]+\") | .string | tonumber] | add' \"\$JSON_FILE\" 2>/dev/null || echo \"0\")
SEND_AVG=\$(echo \"scale=1; \$SEND_TOTAL / \$COUNT\" | bc)
RECV_AVG=\$(echo \"scale=1; \$RECV_TOTAL / \$COUNT\" | bc)
echo \"- **Average Send Speed:** \${SEND_AVG} Mbits/sec\" &&
echo \"- **Average Recv Speed:** \${RECV_AVG} Mbits/sec\"
else
echo 'Network test results not available'
fi
else
echo 'Network test results not available'
fi &&
echo ''
"
@plasmadice
Copy link
Author

Disclaimer: using code from strangers on the internet is dangerous. Investigate before using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment