SPB Git

Repository Public

perf.sh 1.5 KB 29 lines shellscript

1#!/usr/bin/env bash2# SP Chat iOS3# File: Scripts/perf.sh4# Description: Performance measurements on a simulator against a local stand-in backend (Scripts/perf-stub.py: 4505#              models, a 200-message conversation). No model is called. Prints the measured figures.6#              usage: perf.sh   (SPCHAT_SIM selects the simulator)7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10set -uo pipefail11cd "$(dirname "$0")/.."12PORT=859913python3 Scripts/perf-stub.py "$PORT" & STUB=$!14trap 'kill $STUB 2>/dev/null' EXIT15sleep 116export TEST_RUNNER_SPCHAT_BASE_URL="http://localhost:$PORT" TEST_RUNNER_SPCHAT_PERF=117: > build/logs/perf-memory.log18( # resident memory of the app process (a simulator process is a host process), sampled while the tests run19  while sleep 2; do P=$(pgrep -f "SPChat.app/SPChat" | head -1); [ -n "$P" ] && echo "$(date +%s) $(ps -o rss= -p "$P" | tr -d ' ')" >> build/logs/perf-memory.log; done ) & SAMPLER=$!20trap 'kill $STUB $SAMPLER 2>/dev/null' EXIT21Scripts/build.sh uitest -only-testing:SPChatUITests/PerfUITests >/dev/null 2>&122kill $SAMPLER 2>/dev/null23python3 - <<'PY'24rows = [l.split() for l in open("build/logs/perf-memory.log") if len(l.split()) == 2]25rss = [int(r[1]) / 1024 for r in rows if r[1].isdigit()]26if rss: print(f"PERF resident memory MB over the run (simulator, Debug): min {min(rss):.0f} · median {sorted(rss)[len(rss)//2]:.0f} · max {max(rss):.0f} ({len(rss)} samples)")27PY28grep -E "PERF |Test Case.*(passed|failed)|measured \[" build/logs/uitest.log | sed -E 's/.*(Test Case|PERF |measured)/\1/' | cut -c1-33029
Files main
Menu

Theme