#!/bin/bash

SB="$HOME/0.4/sysbench/sysbench"

DB="--pgsql-user=postgres --pgsql-password=password --pgsql-db=sysbench --pgsql-host=localhost --db-driver=pgsql"
#DB="--mysql-user=root --db-driver=mysql --mysql-table-engine=innodb --mysql-db=sysbench"
#THREADS="1 2 3 4 5 6 7 8 9 10 11 12 16 24 32 48 64 96"
THREADS="1"
TIME=10
TEST_PARAM="--oltp-read-only=off --oltp-test-mode=complex"
#TEST_PARAM="--oltp-read-only=on --oltp-test-mode=simple"
SIZES="10000"
#SIZES="10000 100000 1000000 10000000 50000000 100000000 500000000 1000000000"
# In complex, non read-only mode, there will be duplicate key issues, and
# threads will fail with deadlock--causing no value to be returned.
#TEST_PARAM="--oltp-test-mode=complex"

for s in $SIZES
do

SIZE_PARAM="--oltp-table-size=$s"

# Just in case!
$SB $DB --test=oltp cleanup

$SB $DB $SIZE_PARAM --test=oltp prepare 

for t in $THREADS
do
  echo -n $t threads:
  $SB $DB --test=oltp $TEST_PARAM $SIZE_PARAM --init-rng --max-requests=0 --max-time=$TIME --num-threads=$t run 2>&1 # | grep "read/write requests"
done

$SB $DB --test=oltp cleanup

done
