#!/bin/bash # Round01 performance PoC runner. This launches an AppKit/CALayer-only overlay # with 200 simulated window cards and an auto-cycling selected state. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" OUTPUT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" # shellcheck source=build-output-paths.sh source "$SCRIPT_DIR/build-output-paths.sh" SOURCE_ROOT="$OUTPUT_ROOT/C1.source" APP="$BUILD_CURRENT_APP" REPORT="$BUILD_REPORT_ROOT/round01-performance-poc-report.json" require_json_value() { local key="$1" local expected="$2" if ! /usr/bin/python3 - "$REPORT" "$key" "$expected" <<'PY' import json import sys path, key, expected = sys.argv[1:4] with open(path, "r", encoding="utf-8") as handle: data = json.load(handle) actual = data.get(key) if expected == "true": ok = actual is True elif expected == "false": ok = actual is False else: ok = str(actual) == expected if not ok: print(f"{key}: expected {expected}, got {actual}", file=sys.stderr) sys.exit(1) PY then exit 1 fi } require_json_number_at_least() { local key="$1" local minimum="$2" if ! /usr/bin/python3 - "$REPORT" "$key" "$minimum" <<'PY' import json import sys path, key, minimum = sys.argv[1:4] with open(path, "r", encoding="utf-8") as handle: data = json.load(handle) actual = data.get(key) if actual is None or float(actual) < float(minimum): print(f"{key}: expected >= {minimum}, got {actual}", file=sys.stderr) sys.exit(1) PY then exit 1 fi } require_json_number_at_most() { local key="$1" local maximum="$2" if ! /usr/bin/python3 - "$REPORT" "$key" "$maximum" <<'PY' import json import sys path, key, maximum = sys.argv[1:4] with open(path, "r", encoding="utf-8") as handle: data = json.load(handle) actual = data.get(key) if actual is None or float(actual) > float(maximum): print(f"{key}: expected <= {maximum}, got {actual}", file=sys.stderr) sys.exit(1) PY then exit 1 fi } cd "$SOURCE_ROOT" swift build >&2 "$SCRIPT_DIR/package-app.sh" >&2 rm -f "$REPORT" "$APP/Contents/MacOS/Aligner" \ --round0-skip-permissions \ --round01-performance-poc \ --round01-poc-auto-cycle \ --round01-poc-auto-hide-after="${ALIGNER_ROUND1_POC_HIDE_AFTER:-8.0}" \ --round01-poc-quit-after="${ALIGNER_ROUND1_POC_QUIT_AFTER:-10.0}" \ --round01-poc-report="$REPORT" if [[ ! -f "$REPORT" ]]; then echo "Round01 performance PoC report was not created: $REPORT" >&2 exit 1 fi require_json_value cardCount 200 require_json_value appCount 20 require_json_value cardLayerCount 200 require_json_value appLayerCount 20 require_json_value thumbnailLayerCount 200 require_json_value simulatedScreenshotRefillCount 200 require_json_value waterfallScrollable true require_json_value spotlightVisible true require_json_value spotlightAlignedWithSelectedCard true require_json_number_at_least scrollAdjustmentCount 1 require_json_number_at_least scrollOffset 1 require_json_number_at_least firstFrameLatencySampleCount 1 require_json_number_at_most firstFrameLatencyP95Milliseconds 150 require_json_number_at_least keyboardResponseSampleCount 20 require_json_number_at_most keyboardResponseP95Milliseconds 50 require_json_number_at_least hoverResponseSampleCount 20 require_json_number_at_most hoverResponseP95Milliseconds 32 require_json_value performanceGatePassed true cat "$REPORT" printf '\n'