Support time-based runs instead of just ones based
authorGreg Smith <gsmith@gregsmith.com>
Fri, 7 Jan 2011 10:26:51 +0000 (05:26 -0500)
committerGreg Smith <gsmith@gregsmith.com>
Fri, 7 Jan 2011 10:26:51 +0000 (05:26 -0500)
on transaction counts.

benchwarmer
config

index c8059f27c524b28c705ec4b14c0de696916dea7b..0b7355f6ec929874f81cf365e9e60454c9cc46a0 100755 (executable)
@@ -39,6 +39,15 @@ function get_bgwriter {
 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.
@@ -112,7 +121,7 @@ fi
 
 # 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?
@@ -133,8 +142,8 @@ echo This is test $TEST
 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"
@@ -162,7 +171,8 @@ echo Worst latency results:
 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`
diff --git a/config b/config
index 372f43a5e9554ee31b6cb037becb943be89765f6..633aed1dfcc9060c7fd4b722c64b647874375234 100755 (executable)
--- a/config
+++ b/config
@@ -1,3 +1,9 @@
+#
+# 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`
 
@@ -9,10 +15,6 @@ TESTDIR="tests"
 #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
@@ -28,9 +30,25 @@ RESULTUSER="$TESTUSER"
 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