Rudimentary benchmark scripts

This commit is contained in:
2015-03-27 10:24:06 -04:00
parent 1c258caa7f
commit 480aae2bd5
2 changed files with 25 additions and 0 deletions

15
scripts/benchmark.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
n=$1
t=0
all_t=""
TIMEFORMAT=%U
printf "%12s\t%12s\n" "seed" "user-time (s)"
for i in $(seq 0 9); do
t=$( { time bin/hw2.run --gtsp -s $i -n $n > out/gtsp-n${n}-s${i}.log; } 2>&1 )
all_t="$all_t $t"
printf "%12d\t%12.3f\n" $i $t
done
echo
echo $all_t | scripts/mean.r

10
scripts/mean.r Executable file
View File

@@ -0,0 +1,10 @@
#! /usr/bin/env Rscript
gm_mean = function(x, na.rm=TRUE){
exp(sum(log(x[x > 0]), na.rm=na.rm) / length(x))
}
d<-scan("stdin", quiet=TRUE)
cat(sprintf("%12s %12.3f\n", "min", min(d)))
cat(sprintf("%12s %12.3f\n", "max", max(d)))
cat(sprintf("%12s %12.3f\n", "median", median(d)))
cat(sprintf("%12s %12.3f\n", "geom mean", gm_mean(d)))