interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / nodes / tests / measure.sh
| 1 | # ORACLE: host timing harness (sh + curl) for forged page time. Not product code; changes no server state. |
| 2 | # nodes/tests/measure.sh OUTDIR URL: for each route, one warmup request, then 32 timed requests, under |
| 3 | # X-Forge-Base / and then /forge/, two full passes. Writes OUTDIR/times.tsv |
| 4 | # ("pass base route code bytes seconds") and OUTDIR/meta.txt (binary size, sha256, VmRSS/VmHWM of |
| 5 | # the process listening on URL's port, before and after each pass). Docs: docs/PERF.md. |
| 6 | set -eu |
| 7 | OUT=${1:?outdir} |
| 8 | ROOT=${2:?base url} |
| 9 | N=32 |
| 10 | mkdir -p "$OUT" |
| 11 | routes=' |
| 12 | / |
| 13 | /explore |
| 14 | /drakestapleton |
| 15 | /drakestapleton/cuda-crack |
| 16 | /drakestapleton/cuda-crack/tree/main |
| 17 | /drakestapleton/cuda-crack/commits/main |
| 18 | /drakestapleton/cuda-crack/blob/main/README.md |
| 19 | /drakestapleton/cuda-crack/issues |
| 20 | /drakestapleton/cuda-crack/patches |
| 21 | /drakestapleton/cuda-crack/releases |
| 22 | /login |
| 23 | /search?q=omega |
| 24 | /assets/forge.css |
| 25 | ' |
| 26 | port=${ROOT##*:} |
| 27 | pid=$(ss -Htlnp "sport = :$port" | grep -o 'pid=[0-9]*' | head -n 1 | cut -d= -f2 || true) |
| 28 | { |
| 29 | echo "when $(date -u +%Y-%m-%dT%H:%M:%SZ)" |
| 30 | echo "root $ROOT" |
| 31 | echo "pid ${pid:-none}" |
| 32 | if [ -n "$pid" ] && [ -d "/proc/$pid" ]; then |
| 33 | exe=$(readlink -f "/proc/$pid/exe") |
| 34 | echo "exe $exe" |
| 35 | stat -c 'bytes %s' "$exe" |
| 36 | sha256sum "$exe" |
| 37 | awk '/VmRSS|VmHWM|VmSize/ {print}' "/proc/$pid/status" |
| 38 | fi |
| 39 | } > "$OUT/meta.txt" |
| 40 | : > "$OUT/times.tsv" |
| 41 | for pass in 1 2; do |
| 42 | for base in / /forge/; do |
| 43 | if [ "$base" = / ]; then btag=root; else btag=forge; fi |
| 44 | for route in $routes; do |
| 45 | curl -sS -o /dev/null --max-time 60 -H "X-Forge-Base: $base" -H "X-Real-IP: 127.0.0.1" "$ROOT$route" || true |
| 46 | i=1 |
| 47 | while [ "$i" -le "$N" ]; do |
| 48 | curl -sS -o /dev/null -w "$pass $btag $route %{http_code} %{size_download} %{time_total}\n" --max-time 60 \ |
| 49 | -H "X-Forge-Base: $base" -H "X-Real-IP: 127.0.0.1" "$ROOT$route" >> "$OUT/times.tsv" || echo "$pass $btag $route 000 0 0" >> "$OUT/times.tsv" |
| 50 | i=$((i+1)) |
| 51 | done |
| 52 | done |
| 53 | done |
| 54 | if [ -n "$pid" ] && [ -d "/proc/$pid" ]; then |
| 55 | echo "after pass $pass" >> "$OUT/meta.txt" |
| 56 | awk '/VmRSS|VmHWM/ {print}' "/proc/$pid/status" >> "$OUT/meta.txt" |
| 57 | fi |
| 58 | done |
| 59 | echo DONE >> "$OUT/meta.txt" |