ttrie-0.1.0.0: benchmarks/run.sh
#!/bin/sh
main() {
THREADS="[1,2,4,6,8,12,16,24,32,48,64,96,128]"
NUM_TX="250000"
# weights for the transaction's size distribution
TX_SIZES[0]="[(1,5),(2,5),(3,4),(4,4),(5,3),(6,3),(7,2),(8,2),(9,1),(10,1)]"
TX_SIZES[1]="[(1,2),(2,3),(3,4),(4,4),(5,5),(6,4),(7,3),(8,2),(9,1),(10,1)]"
TX_SIZES[2]="[(1,1),(2,1),(3,2),(4,2),(5,3),(6,3),(7,4),(8,4),(9,5),(10,5)]"
# distributions of (lookup,insert,update,delete)
OP_DISTS[0]="(20,60,15,5)"
OP_DISTS[1]="(20,15,60,5)"
OP_DISTS[2]="(80,10,5,5)"
OP_DISTS[3]="(40,20,15,5)"
TX_SIZES_NAMES=("small" "medium" "large")
OP_DISTS_NAMES=("insert" "update" "lookup" "balanced")
for i in ${!TX_SIZES[@]}; do
TX_SIZE=${TX_SIZES[$i]}
for j in ${!OP_DISTS[@]}; do
OP=${OP_DIST[$j]}
mkdir -p "results"
ni=${TX_SIZES_NAMES[$i]}
nj=${OP_DISTS_NAMES[$j]}
n="results/$ni-$nj"
unbuffer cabal bench bench1 --benchmark-options="$THREADS $NUM_TX $TX_SIZE $OP_DIST --regress allocated:iters +RTS -T" |
tee "$n.txt"
cat "$n.txt" | extract_times | transpose > "$n-time.dat"
cat "$n.txt" | extract_allocations | transpose > "$n-alloc.dat"
cat "$n.txt" | extract_retries | transpose > "$n-retries.dat"
done
done
}
extract_retries() {
grep -E "collecting|Retries" |
sed -E 'N;s/[^0-9]*([0-9]+)\/[0-9]+\/(.*)\n[^0-9]*([0-9\.e]*)/\2 \1 \3/g'
}
extract_times() {
grep -E "benchmarking|time" |
sed -E "s/time *([0-9\.]*) s.*/\1/g" |
sed -E "s/time *([0-9]*)\.([0-9]*) ms.*/0.\1\2/g" |
sed -E "N;s/[^0-9]*([0-9]+)\/[0-9]+\/(.*)\n(.*)/\2 \1 \3/g"
}
extract_allocations() {
grep -E "benchmarking|iters" |
sed -E "N;s/[^0-9]*([0-9]+)\/[0-9]+\/(.*)\n[^0-9]*([0-9\.e]*).*/\2 \1 \3/g"
}
transpose() {
awk '{names[$1]++; threads[0]=0; threads[$2]++; results[$1,0]="\""$1"\""; results[$1,$2]=$3}END{for (t in threads) { printf "%s",t; for (n in names) printf " %s",results[n,t]; printf "\n" }}' | sort -n
}
main "$@"