TRANS=`expr $TOTTRANS / $CLIENTS`
TOTTRANS=`expr $TRANS \* $CLIENTS`
+# If a runtime has been specified instead, throw away the transaction counts
+# use it instead
+if [ -n "$RUNTIME" ] ; then
+ TESTLEN="-T $RUNTIME"
+ TOTTRANS=""
+else
+ TESTLEN="-t $TRANS"
+fi
+
# Set WORKERS string so that the largest possible worker count
# up to MAX_WORKERS is used, while still dividing CLIENTS into an
# even number per worker.
# Create the tests record
DBSIZE=`$TESTPSQL -A -t -c "select pg_database_size('$TESTDB')"`
-$RESULTPSQL -q -c "insert into tests (script,clients,workers,trans,set,scale,dbsize) values('$SCRIPT','$CLIENTS','$NUM_WORKERS','$TOTTRANS','$SET','$SCALE','$DBSIZE')"
+$RESULTPSQL -q -c "insert into tests (script,clients,workers,set,scale,dbsize) values('$SCRIPT','$CLIENTS','$NUM_WORKERS','$SET','$SCALE','$DBSIZE')"
TEST=`$RESULTPSQL -A -t -c "select max(test) from tests"`
if [ "$?" -ne "0" ]; then
echo ERROR Can\'t read from tests table. Was the test data installed?
mkdir -p results/$TEST
cd results/$TEST
-echo Script $SCRIPT executing $TRANS transactions for each of $CLIENTS concurrent users... 1>&2
-$PGBENCHBIN -f $BASEDIR/$TESTDIR/$SCRIPT -s $SCALE -l -n -U $TESTUSER -t $TRANS -h $TESTHOST -p $TESTPORT -c $CLIENTS $WORKERS $TESTDB > results.txt &
+echo Script $SCRIPT executing for $CLIENTS concurrent users... 1>&2
+$PGBENCHBIN -f $BASEDIR/$TESTDIR/$SCRIPT -s $SCALE -l -n $TESTLEN -U $TESTUSER -h $TESTHOST -p $TESTPORT -c $CLIENTS $WORKERS $TESTDB > results.txt &
P=$!
wait $P
$RESULTPSQL -q -c "update tests set end_time=now() where test=$TEST"
cat pgbench.log | cut -f 3 -d " " | sort -n | tail -n 5
tps=`grep "(including connections establishing)" results.txt | cut -d " " -f 3`
-$RESULTPSQL -q -c "update tests set tps='$tps' where test=$TEST"
+trans=`grep "number of transactions actually processed:" results.txt | cut -d":" -f 2 | cut -d "/" -f 1`
+$RESULTPSQL -q -c "update tests set tps='$tps',trans='$trans' where test=$TEST"
# Confirm we have an patched version of pgbench that has timestamps
TESTFORTS=`cat pgbench.log | head -n 1 | cut -d" " -f 6`
+#
+# Basic setup options. If you are running as the postgres user and
+# are using PostgreSQL 8.4 or later, you normally don't need to
+# change any of these.
+#
+
BASEDIR=`pwd`
PGBENCHBIN=`which pgbench`
#TABLEPREFIX=""
#TESTDIR="tests-8.3"
-# Set this to a number only when using pgbench 9.0 or later. This will set
-# the number of worker threads up to this maximum for each client count
-MAX_WORKERS=""
-
# SKIPINIT should be set to 1 either when simulating a cold cache, or
# if you are not using the pgbench tables for your test
SKIPINIT=0
RESULTPORT="$TESTPORT"
RESULTDB=results
-# Test run customization
+#
+# Main test run customization
+#
+
+# Set this to a number only when using pgbench 9.0 or later. This will set
+# the number of worker threads up to this maximum for each client count
+MAX_WORKERS=""
+
SCRIPT="select.sql"
-TOTTRANS=100000
-SETCLIENTS="1 2 4 8 16 32"
SCALES="1 10 100 1000"
+SETCLIENTS="1 2 4 8 16 32"
SETTIMES=3
+
+# RUNTIME is in seconds. If it is specified, then TOTTRANS is ignored.
+# Setting a time instead of a transaction account is only available
+# in 8.4 and later.
+RUNTIME=60
+TOTTRANS=""
+
+# Use a transaction count instead for 8.3 or earlier
+#RUNTIME=""
+#TOTTRANS=100000