planckforth/benchmark/gendoc.sh

50 lines
1.3 KiB
Bash
Raw Normal View History

2021-01-11 08:22:56 +01:00
#!/bin/bash
2021-05-05 18:31:24 +02:00
PRNUM="$1"
2021-01-11 09:28:57 +01:00
TARGETS="i386-linux-handwritten c python"
2021-01-11 08:22:56 +01:00
TIMEFORMAT='%U'
2021-01-11 12:11:41 +01:00
CPU_MODEL=`cat /proc/cpuinfo | grep -m1 'model name' | cut -d: -f2 | sed "s/^ *//g"`
2021-01-11 11:53:40 +01:00
MEM_SIZE="`cat /proc/meminfo | grep 'MemTotal' | awk '{ print $2/1024/1024 }'` GB"
UNAME=`uname -a`
2021-01-11 08:22:56 +01:00
function benchmark () {
sum=0
for i in `seq $2`; do
t=`{ eval $1; } 2>&1`
sum=`echo $t + $sum | bc`
done
average=`echo "scale=3; $sum / $2" | bc | xargs printf "%.3f"`
echo $average
}
function generate-table {
2021-01-11 11:53:40 +01:00
echo "## $1"
2021-01-11 09:28:57 +01:00
echo "\`$2\`"
2021-01-11 10:04:05 +01:00
echo
#echo "Average of $3 execution times."
#echo
2021-01-11 11:31:08 +01:00
echo "| runtime implementation | execution time (sec) |"
echo "|:-----------------------|---------------------:|"
2021-01-11 08:22:56 +01:00
for impl in $TARGETS; do
make $impl 2>&1 > /dev/null
2021-01-11 11:31:08 +01:00
runtime=`./planck < bootstrap.fs --runtime`
2021-01-11 09:28:57 +01:00
t=`benchmark "time $2 2>&1 > /dev/null" $3`
2021-01-11 11:31:08 +01:00
echo "| $runtime | $t |"
2021-01-11 08:22:56 +01:00
done
2021-01-11 09:28:57 +01:00
echo
2021-01-11 09:21:32 +01:00
}
2021-01-11 08:22:56 +01:00
2021-01-11 11:53:40 +01:00
echo "# Environment"
echo
2021-05-05 19:00:18 +02:00
echo "- Commit: #$PRNUM"
2021-01-11 11:53:40 +01:00
echo "- $CPU_MODEL"
echo "- $MEM_SIZE"
echo "- $UNAME"
echo
echo "# Benchmarks"
generate-table "Bootstrap Time" "./planck < bootstrap.fs benchmark/nop.fs" 1
generate-table "Fib(30)" "./planck < bootstrap.fs benchmark/fib.fs" 1
2021-01-11 13:03:56 +01:00
generate-table "Matmul" "./planck < bootstrap.fs benchmark/matmul.fs" 1