#!/bin/sh

clients="32 80 1 8 16 24"
times="300"
scales="100"
types="p"
branches="master clog32 clog16 clog48"

~/install/master/bin/pg_ctl stop -mf

for x in 1 2 3 4 5; do
  for client in $clients; do
    for time in $times; do
      for scale in $scales; do
        for branch in $branches; do
          for type in $types; do
            ident="w$type.$branch.$client.$scale.$time"
			echo "run=$x clients=$client time=$time scale=$scale branch=$branch type=$type"
			~/install/$branch/bin/pg_ctl start -l ~/log/log.$ident
			sleep 5
			~/install/$branch/bin/dropdb --if-exists rhaas
			~/install/$branch/bin/createdb rhaas
			if [ $type = u ]; then
				~/install/master/bin/pgbench -i -s $scale --unlogged-tables
			else
				~/install/master/bin/pgbench -i -s $scale
			fi
			sleep 5
			~/install/master/bin/pgbench -T $time -c $client -j $client $extraopts \
				>> ~/results/results$ident
			psql -c CHECKPOINT
			~/install/$branch/bin/pg_ctl stop -m fast
			sleep 5
          done
		done
	  done
	done
  done
done
