From b492aaff19dab9e87a08a2d38bf6ab16fff63bee Mon Sep 17 00:00:00 2001 From: Greg Smith Date: Fri, 7 Jan 2011 05:26:51 -0500 Subject: [PATCH] Support time-based runs instead of just ones based on transaction counts. --- benchwarmer | 18 ++++++++++++++---- config | 32 +++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/benchwarmer b/benchwarmer index c8059f2..0b7355f 100755 --- a/benchwarmer +++ b/benchwarmer @@ -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 372f43a..633aed1 100755 --- 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 -- 2.39.5