Split benchmark file system setup and execution into separate steps.
[bluesky.git] / microbench / setup / prepare-benchmark
diff --git a/microbench/setup/prepare-benchmark b/microbench/setup/prepare-benchmark
new file mode 100755 (executable)
index 0000000..0102705
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# Prepare a file system for a benchmark run by creating any needed files or
+# directories.
+
+
+# Defaults
+SERVER=c09-45.sysnet.ucsd.edu
+MNTDIR=/mnt/bluesky
+
+BENCH_FILESIZE=$((1 << 12))
+BENCH_FILECOUNT=$((8))
+BENCH_WRITERATIO=1.0
+BENCH_THREADS=8
+BENCH_DURATION=120
+BENCH_OPS=100
+BENCH_INTERVALS=4
+
+# Export any environment variables specified on the command line
+for e in "$@"; do
+    echo "$e" 1>&2
+    if echo "$e" | grep = >/dev/null; then
+        eval "$e"
+        export ${e%=*}
+    fi
+done
+
+# Prepare to run the benchmark
+mount -t nfs -o vers=3,tcp,rw,soft,intr $SERVER:/export $MNTDIR
+
+pushd $MNTDIR >/dev/null
+
+for t in $(seq 0 $(($BENCH_THREADS - 1))); do
+    mkdir t$t
+    for i in $(seq 0 $(($BENCH_FILECOUNT - 1))); do
+        dd if=/dev/zero of=t$t/$i bs=$BENCH_FILESIZE count=1
+    done
+done
+
+popd >/dev/null
+
+umount -f $MNTDIR