From: Bart Van Assche Date: Sat, 7 Jun 2008 11:40:14 +0000 (+0000) Subject: Reorganized SPLASH-2 benchmarking script. X-Git-Tag: svn/VALGRIND_3_4_0~504 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f895b20c0cbf00e21b90b195bf30a80c860ed1a4;p=thirdparty%2Fvalgrind.git Reorganized SPLASH-2 benchmarking script. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8200 --- diff --git a/exp-drd/scripts/measurement-functions b/exp-drd/scripts/measurement-functions new file mode 100644 index 0000000000..0264da6ca9 --- /dev/null +++ b/exp-drd/scripts/measurement-functions @@ -0,0 +1,69 @@ +#!/bin/bash + +######################## +# Function definitions # +######################## + +## Print the logarithm base 2 of $1 on stdout. +function log2 { + local i + + for ((i=0;i<64;i++)) + do + if [ $((2**i)) = $1 ]; then + echo $i + return 0 + fi + done + echo error + return 1 +} + +## Print the size of the level 2 cache in bytes on stdout. +function get_cache_size { + local s + s=$(0?sqrt(d):0)}' +} + +## Echo all arguments on stderr, run the command passed in $1 .. ${$#} three +# times, pass the file specified in ${test_input} to the command, write the +# command output to the file specified in ${test_output}, and print the +# runtime of the command on stdout. +function measure_runtime { + echo "$@" >&2 + for ((i=0;i<3;i++)) + do + cat "${test_input:-/dev/null}" | \ + /usr/bin/time --format="%e" "$@" 2>&1 | \ + tee "${test_output:-/dev/null}" | \ + tail -n 1 + done +} + +## Print the average runtime of the command passed in $1 .. ${$#} and the ratio +# of the runtime to ${avg1} +/- ${stddev1}. +function print_runtime_ratio { + local tmp + + tmp="/tmp/test-timing.$$" + rm -f "${tmp}" + + measure_runtime "$@" | avgstddev > "$tmp" + read avg2 stddev2 < "$tmp" + echo "Average time: ${avg2} +/- ${stddev2} seconds" + awk "END{print "'"'"Ratio ="'"'", ${avg2}/${avg1}, "'"'"+/-"'"'", ${avg2}/${avg1}*(${stddev1}/${avg1}+${stddev2}/${avg2})}" 0?sqrt(d):0)}' -} +source "$(dirname $0)/measurement-functions" function run_test { local tmp avg1=1 stddev1=1 avg2=1 stddev2=1 @@ -42,42 +12,17 @@ function run_test { tmp="/tmp/test-timing.$$" rm -f "${tmp}" - echo "$@" - for ((i=0;i<3;i++)) - do - cat "${test_input:-/dev/null}" | \ - /usr/bin/time --format="%e" "$@" 2>&1 | \ - tee "${1}.out" | \ - tail -n 1 - done | avgstddev > "$tmp" + test_output="${1}.out" measure_runtime "$@" | avgstddev > "$tmp" read avg1 stddev1 < "$tmp" echo "Average time: ${avg1} +/- ${stddev1} seconds" for p in 1 2 4 do - echo "$VG --tool=exp-drd --check-stack-var=yes $@ -p$p" - for ((i=0;i<3;i++)) - do - cat "${test_input:-/dev/null}" | \ - /usr/bin/time --format="%e" $VG --tool=exp-drd "$@" -p$p 2>&1 | \ - tee "${1}-drd-with-stack-var-${p}.out" | \ - tail -n 1 - done | avgstddev > "$tmp" - read avg2 stddev2 < "$tmp" - echo "Average time: ${avg2} +/- ${stddev2} seconds" - awk "END{print "'"'"Ratio ="'"'", ${avg2}/${avg1}, "'"'"+/-"'"'", ${avg2}/${avg1}*(${stddev1}/${avg1}+${stddev2}/${avg2})}" &1 | \ - tee "${1}-drd-without-stack-var-${p}.out" | \ - tail -n 1 - done | avgstddev > "$tmp" - read avg2 stddev2 < "$tmp" - echo "Average time: ${avg2} +/- ${stddev2} seconds" - awk "END{print "'"'"Ratio ="'"'", ${avg2}/${avg1}, "'"'"+/-"'"'", ${avg2}/${avg1}*(${stddev1}/${avg1}+${stddev2}/${avg2})}"