From 968e0c283824311f792ccc454dbdd50792139d0d Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Mon, 11 Jan 2021 17:28:57 +0900 Subject: [PATCH] Add new benchmark --- benchmark/fib.fs | 2 ++ benchmark/gendoc.sh | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 benchmark/fib.fs diff --git a/benchmark/fib.fs b/benchmark/fib.fs new file mode 100644 index 0000000..1f7bfa7 --- /dev/null +++ b/benchmark/fib.fs @@ -0,0 +1,2 @@ +: fib dup 2 < unless 1- dup recurse swap 1- recurse + then ; +20 fib . cr diff --git a/benchmark/gendoc.sh b/benchmark/gendoc.sh index b04658b..d2f0a40 100755 --- a/benchmark/gendoc.sh +++ b/benchmark/gendoc.sh @@ -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