#!/usr/bin/env bash
# Second half of the timed runs (after the x1000 all-persona run was cut short
# for time on a loaded machine; see README). One persona per account at x1000.
set -uo pipefail
HERE=$(cd "$(dirname "$0")/.." && pwd); R="$HERE/results"; S="$HERE/scripts"
echo "rest start $(date -u +%FT%TZ)" | tee -a "$R/run_all.log"
node "$S/rls_query_timing.mjs" wc_bench_x1000 1 1,7,9,14 > "$R/exp2_query_x1000.jsonl"
echo "exp2 query timing done $(date -u +%T)" | tee -a "$R/run_all.log"
"$S/run_pgbench.sh" wc_bench_x0 5 20 | tee "$R/exp2_pgbench_x0_summary.txt"
"$S/run_pgbench.sh" wc_bench_x50 5 20 | tee "$R/exp2_pgbench_x50_summary.txt"
echo "pgbench done $(date -u +%T)" | tee -a "$R/run_all.log"
node "$S/helper_overhead.mjs" wc_bench_x1000 3 > "$R/exp2_helper_overhead.jsonl"
echo "helper done $(date -u +%T)" | tee -a "$R/run_all.log"
for v in before after; do
  EXP_DB=wcmin_$v node "$S/audit_experiments.mjs" lockscope $v 30 5000 > "$R/min_lockscope_$v.jsonl"
  EXP_DB=wcmin_$v node "$S/audit_experiments.mjs" interleave $v 200 > "$R/min_interleave_$v.jsonl"
  EXP_DB=wcmin_$v node "$S/audit_experiments.mjs" stress $v 100 8 5 > "$R/min_stress_$v.jsonl"
done
echo "end $(date -u +%FT%TZ)" | tee -a "$R/run_all.log"
