#!/bin/sh # Measure the owned local API process RSS while ten clients upload concurrently. set -eu : "${API_PID:?Pass the PID of this lab API}" "${BASE_URL:=http://127.0.0.1:18084}" mkdir -p evidence/current sampler= cleanup() { if [ -n "$sampler" ]; then kill "$sampler" 2>/dev/null || true; wait "$sampler" 2>/dev/null || true; fi } trap cleanup EXIT INT TERM ( while kill -0 "$API_PID" 2>/dev/null; do ps -o rss= -p "$API_PID" sleep 0.1 done ) > evidence/current/upload-rss-kib.txt & sampler=$! BASE_URL="$BASE_URL" k6 run --summary-export evidence/current/upload-summary.json student-tests/load/attachments.js > evidence/current/upload.txt 2>&1 awk 'BEGIN {max=0} $1>max {max=$1} END {print "peak_rss_kib=" max}' evidence/current/upload-rss-kib.txt