From aa6a07918280fc9a799f431f1e5c3f50c8325920 Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sat, 30 Mar 2013 17:15:05 -0500 Subject: [PATCH] Add bench framework --- .gitignore | 1 + bench | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100755 bench diff --git a/.gitignore b/.gitignore index 41ca5f0..ec1bf48 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ contrib +log diff --git a/bench b/bench new file mode 100755 index 0000000..ad197e4 --- /dev/null +++ b/bench @@ -0,0 +1,67 @@ +#!/bin/sh + +_root="$(dirname "${0}")"; . "${_root}/lib/sh/env.sh" +want log suexec + +[ "$(hostname -s)" = "nabihinew" ] || wtf "Run this on nabihinew only!" + +suexec "${0}" "${@}" + +want stopwatch + +# Environment and needed stuff +tests="${_root}/tests" + +# Log maintenance +logs="${_root}/log" +[ -d "${logs}" ] || mkdir -p "${logs}" +run_log="${logs}/bench-$(date +%Y-%m-%d_%H:%M:%S).log" + +# Scratch directory maintenance +scratch="/bonnie" +prepare_scratch() { + [ -d "${scratch}" ] || mkdir -p "${scratch}" + mount | grep -q ' on '"${scratch}"' ' && umount "${scratch}" || true + find "${scratch}" -uid "${bonnie_uid}" -xdev -delete +} + +# Bonnie setup +bonnie_uid="4444" +bonnie_opts="-d /bonnie -u ${bonnie_uid} -s 12288 -n 16:16384:0 -f 0" +bonnie_log="${logs}/bonnie-%s-$(date +%Y-%m-%d_%H:%M:%S).csv" +run_bonnie() { + chown "${bonnie_uid}" "${scratch}" + /usr/local/sbin/bonnie++ ${bonnie_opts} -m "${test}" | tee -a "$(printf "${bonnie_log}" "${test}")" +} + +# Default methods +setup() { + prepare_scratch +} +run() { + run_bonnie +} +teardown() { + prepare_scratch +} + +# Main event +if [ "${#}" -eq 0 ] +then + log "Considering tests: $(cd "${tests}"; echo *)" | tee -a "${run_log}" + ( cd "${tests}"; ls -1 ) | script -a "${run_log}" xargs -L1 "${0}" +else + test="${1}"; shift + testfile="${tests}/${test}" + [ -f "${testfile}" ] || wtf "Test '${test}' does not exist" + prepare_scratch + ( log "Loading test: ${test}" + . "${testfile}" + prepare_scratch + setup + log "$(stopwatch run start)" + run; result=$? + log "$(stopwatch run stop) Test result ${result}" + teardown + ) +fi -- 2.42.0