Crank up dbench, now that everything seems to be quite stable under load.
[xfstests-dev.git] / bench
diff --git a/bench b/bench
index fc7989bd0502d94eb8bf1a6bacb6e14d33231189..cd7bc37dfdd92e74e367193028058201496f1570 100755 (executable)
--- a/bench
+++ b/bench
@@ -1,7 +1,7 @@
 #!/bin/sh
 # 
 # Wrapper for automating benchmarking runs.
-# Usage:   bench [passes] [user] [group] [script]
+# Usage:   bench passes user group [script]
 # 
 # ..where passes is the number of times to run each script; uid/gid
 # gives credentials to use when running the script; and script is a
@@ -50,8 +50,7 @@
 owner=nathans@sgi.com
 
 tmp=/tmp/$$
-seq=bench
-here=`pwd`
+here=`pwd`; export here
 status=1       # failure is the default!
 
 # get standard environment, filters and checks
@@ -64,11 +63,9 @@ _cleanup()
     umount $SCRATCH_DEV >/dev/null 2>&1
 }
 
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
-ROOT="."
-LOG="$ROOT/bench.log"
-FULL="$ROOT/bench.full"
+OUT="bench.out"
+LOG="bench.log"
+FULL="bench.full"
 
 _log()
 {
@@ -100,7 +97,7 @@ _run_benchmark()
     do
         _log "        *** clean scratch device [$bench starting, pass $pass]"
         mkfs_xfs -f $SCRATCH_DEV 2>&1 |  _fix_malloc >>$FULL \
-                        || _fail "            !!! failed to mkfs SCRATCH_DEV"
+                            || _fail "            !!! mkfs SCRATCH_DEV failed"
 
         _log "        *** mounting scratch device"
         mount -t xfs $SCRATCH_DEV $SCRATCH_MNT \
@@ -111,12 +108,17 @@ _run_benchmark()
                             || _fail "            !!! couldn't mkdir benchdir"
         chown -R $user.$group $SCRATCH_MNT/bench \
                             || _fail "            !!! couldn't chown benchdir"
+
         cd $SCRATCH_MNT/bench
+        seq=`perl -e 'printf "results.%s.%03d\n", '$bench', '$pass`
+        rm -f $seq $tmp.out
+
+        _log "        *** bench [$seq]"
+        $here/src/runas -u $uid -g $gid $here/run.$bench > $tmp.out
+       [ $? -eq 0 ]        || _fail "            !!! $bench pass $pass failed"
 
-        _log "        *** bench [src/runas -u $uid -g $gid run.$bench]"
-        $here/src/runas -u $uid -g $gid $here/run.$bench | _logp
-        [ $? -eq 0 ]        || _fail "            !!! non-zero $bench status"
         cd $here
+        _fix_malloc < $tmp.out > $seq
 
         _log "        *** unmounting scratch device"
         umount $SCRATCH_DEV 2>&1 | _logp \
@@ -129,32 +131,44 @@ _run_benchmark()
     done
 }
 
+_merge_results()
+{
+    echo Results for $bench benchmark >>$OUT
+    echo results.$bench.* | sort -nu | xargs cat >>$OUT
+    echo >>$OUT
+}
+
 # real QA test starts here
 
-_require_scratch
+if [ $# -lt 3 ]; then
+    echo Usage:  bench passes user group [script]
+    exit 1
+fi
 
-passes=-1
-user=root
-group=root
-benches=`echo run.* | sed -e 's/run\.//g'`
+passes=$1
+user=$2
+group=$3
 
-[ $# -gt 0 ] && passes=$1
-[ $# -gt 1 ] && user=$2
-[ $# -gt 2 ] && group=$3
+benches=`echo run.* | sed -e 's/run\.//g'`
 [ $# -gt 3 ] && benches=$4
-
 [ -z "$benches" -o "$benches" = "*" ] && _fail "no benchmark scripts found"
 
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_require_scratch
+
+rm -f bench.*
 for bench in $benches
 do 
     echo "" >$FULL
     echo "" >$LOG
-    _log "*** benchmark started (passes=$passes, benchmark=$bench)"
-    _log "***     (`date`)"
+    _log "*** benchmark started [passes=$passes, benchmark=$bench]"
+    _log "*** (`date`)"
     _log "        *** unmounting scratch device"
     umount $SCRATCH_DEV 2>&1 | _fix_malloc >>$FULL
 
-    _run_benchmark |  _fix_malloc
+    _run_benchmark | _fix_malloc
+    _merge_results
 
     _log "*** done $bench"
 done