Add new benchmark

This commit is contained in:
Koichi Nakamura 2021-01-11 17:28:57 +09:00
parent 56b990c297
commit 968e0c2838
2 changed files with 8 additions and 7 deletions

2
benchmark/fib.fs Normal file
View file

@ -0,0 +1,2 @@
: fib dup 2 < unless 1- dup recurse swap 1- recurse + then ;
20 fib . cr

View file

@ -1,6 +1,6 @@
#!/bin/bash
TARGETS="i386-linux-handwritten c"
TARGETS="i386-linux-handwritten c python"
TIMEFORMAT='%U'
function benchmark () {
sum=0
@ -12,21 +12,20 @@ function benchmark () {
echo $average
}
function bootstrap {
time ./planck < bootstrap.fs benchmark/nop.fs 2>&1 > /dev/null
}
function generate-table {
echo "## $1"
echo "\`$2\`"
echo
echo "| implementation | sec |"
echo "|:---------------|----:|"
for impl in $TARGETS; do
make $impl 2>&1 > /dev/null
t=`benchmark $2 $3`
t=`benchmark "time $2 2>&1 > /dev/null" $3`
echo "| $impl | $t |"
done
echo
}
echo "# Benchmarks"
generate-table "Bootstrap Time" bootstrap 5
generate-table "Bootstrap Time" "./planck < bootstrap.fs benchmark/nop.fs" 1
generate-table "Fib(20)" "./planck < bootstrap.fs benchmark/fib.fs" 1