#!/bin/bash

export PGHOST=localhost
export PGPORT=5433

#for scale in 100 400 4000 ; do
for scale in 4000 ; do
  for run in 1 2 3 4 5 ; do
    ( (
        set -x
        dropdb pgbench || :
        createdb pgbench
        time ./tmp_install/usr/local/pgsql/bin/pgbench -i -s "${scale}" pgbench
        time sync
        sleep 60
        time psql pgbench -c 'delete from pgbench_accounts';
        time sync
        sleep 60
        time vacuumdb pgbench -t pgbench_accounts -v
        dropdb pgbench
    ) 2>&1 | tee "vacuum_bench_s${scale}.${run}.log" 2>&1 ) &
    iostat -x -m -d 60 > "vacuum_iostat_s${scale}.${run}.log" &
    jobs
    wait %1
    kill %2
    wait
  done
done

