#!/usr/bin/env bash
set -euo pipefail

PYTHON=~/typeagent/.venv/bin/python
OUTDIR="$HOME/results/tests"
mkdir -p "$OUTDIR"

cd ~/typeagent

echo "=== typeagent offline E2E test benchmark ==="
echo ""

# Run offline tests with timing (direct venv to avoid uv run overhead)
$PYTHON -m pytest \
  tests/test_incremental_index.py \
  tests/test_add_messages_with_indexing.py \
  tests/test_podcast_incremental.py \
  tests/test_sqlite_indexes.py \
  tests/test_query.py \
  --durations=0 -v 2>&1 | tee "$OUTDIR/test_output.txt"

# Hyperfine on the full offline suite
hyperfine --warmup 2 --min-runs 10 --shell=none \
  --export-json "$OUTDIR/test_suite.json" \
  "$PYTHON -m pytest tests/test_incremental_index.py tests/test_add_messages_with_indexing.py tests/test_podcast_incremental.py tests/test_sqlite_indexes.py tests/test_query.py -q"
