Hosting Script Generator
Pick a script type, enter your details, and copy the customized command.
Choose Script
Your Script
#!/bin/bash
# TTFB Test Script — generated by StackForge
# Domain: example.com
# Runs 5 times, drops high/low, averages the rest — same methodology as StackForge benchmarks
URL="https://example.com"
RUNS=5
declare -a results
echo "=== TTFB Test for $URL ==="
echo "Running $RUNS tests..."
echo ""
for i in $(seq 1 $RUNS); do
ttfb=$(curl -o /dev/null -s -w "%{time_starttransfer}" "$URL")
ms=$(echo "$ttfb * 1000" | bc | xargs printf "%.0f")
results+=($ms)
echo " Run $i: ${ms}ms"
done
# Sort and drop high/low
sorted=($(echo "${results[@]}" | tr ' ' '\n' | sort -n))
trimmed=("${sorted[@]:1:$((${#sorted[@]}-2))}")
total=0
for val in "${trimmed[@]}"; do total=$((total + val)); done
avg=$((total / ${#trimmed[@]}))
echo ""
echo "Results (sorted): ${sorted[@]}"
echo "After dropping high/low: ${trimmed[@]}"
echo ""
echo "✓ Average TTFB: ${avg}ms"
echo ""
if [ $avg -lt 400 ]; then
echo " Rating: ✓ Excellent (<400ms)"
elif [ $avg -lt 600 ]; then
echo " Rating: ⚠ Average (400–600ms) — consider upgrading"
else
echo " Rating: ✗ Slow (>600ms) — strong case for switching hosts"
fi⚠️ Always review scripts before running in production. StackForge is not liable for damages.