From: Ulya Trofimovich Date: Wed, 2 Aug 2017 14:49:07 +0000 (+0100) Subject: Added scripts that run benchmarks. X-Git-Tag: 1.0~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d60509ee84c046ef73dbfa2d6cd9210eb781dc98;p=re2c Added scripts that run benchmarks. --- diff --git a/re2c/benchmarks/__bench_utils.sh b/re2c/benchmarks/__bench_utils.sh new file mode 100644 index 00000000..fda54957 --- /dev/null +++ b/re2c/benchmarks/__bench_utils.sh @@ -0,0 +1,112 @@ + +re2c="../../re2c" + +compile() { + name="${1}_${2}" + opts="$3" + + [ -e ${re2c} ] || { echo "*** no re2c ***"; exit 1; } + + ${re2c} ${opts} -W ${name}.re -o ${name}_lookahead.c && ls -l --block-size=K ${name}_lookahead.c + ${re2c} ${opts} --no-lookahead -W ${name}.re -o ${name}_no_lookahead.c && ls -l --block-size=K ${name}_no_lookahead.c + ${re2c} ${opts} -W ${name}_notags.re -o ${name}_notags.c && ls -l --block-size=K ${name}_notags.c +} + +run() { + name1="$1" + name2="$2" + name="${name1}_${name2}" + input="../gen/${name1}.dat" + + [ -e ${input} ] || { echo "*** no input file ***"; exit 1; } + + strip ${name} + cmd="./${name} ${input}" + for i in `seq 1`; do $cmd >/dev/null 2>&1; done # warmup + + npass=4 + total=0 + for i in `seq $npass`; do + t="`TIMEFORMAT='%E'; time ( $cmd 2>/dev/null ) 2>&1 1>/dev/null`" + echo "t:" $t + total=`echo $total + $t | bc -l` + done + average=`echo "$total / $npass" | bc -l` + echo "time: $average" + + ls -l --block-size=K ${name} +} + +#cflags="-Wall -O2" +cflags="-O2" + +run_all() { + name1="$1" + name2="$2" + name="${name1}_${name2}" + + echo "---------------- GCC -O2 lookahead ----------------" + gcc $cflags ${name}_lookahead.c -o${name} && run ${name1} ${name2} + echo "---------------- GCC -O2 no-lookahead ----------------" + gcc $cflags ${name}_no_lookahead.c -o${name} && run ${name1} ${name2} + echo "---------------- GCC -O2 notags ----------------" + gcc $cflags ${name}_notags.c -o${name} && run ${name1} ${name2} + + echo "---------------- CLANG -O2 lookahead ----------------" + clang $cflags ${name}_lookahead.c -o${name} && run ${name1} ${name2} + echo "---------------- CLANG -O2 no-lookahead ----------------" + clang $cflags ${name}_no_lookahead.c -o${name} && run ${name1} ${name2} + echo "---------------- CLANG -O2 notags ----------------" + clang $cflags ${name}_notags.c -o${name} && run ${name1} ${name2} + + echo "---------------- TCC -O2 lookahead ----------------" + tcc $cflags ${name}_lookahead.c -o${name} && run ${name1} ${name2} + echo "---------------- TCC -O2 no-lookahead ----------------" + tcc $cflags ${name}_no_lookahead.c -o${name} && run ${name1} ${name2} + echo "---------------- TCC -O2 notags ----------------" + tcc $cflags ${name}_notags.c -o${name} && run ${name1} ${name2} + + echo "---------------- PCC -O2 lookahead ----------------" + pcc $cflags ${name}_lookahead.c -o${name} && run ${name1} ${name2} + echo "---------------- PCC -O2 no-lookahead ----------------" + pcc $cflags ${name}_no_lookahead.c -o${name} && run ${name1} ${name2} + echo "---------------- PCC -O2 notags ----------------" + pcc $cflags ${name}_notags.c -o${name} && run ${name1} ${name2} + +# echo "---------------- NWCC -O2 lookahead ----------------" +# nwcc $cflags ${name}_lookahead.c -o${name} && run ${name1} ${name2} +# echo "---------------- NWCC -O2 no-lookahead ----------------" +# nwcc $cflags ${name}_no_lookahead.c -o${name} && run ${name1} ${name2} +# echo "---------------- NWCC -O2 notags ----------------" +# nwcc $cflags ${name}_notags.c -o${name} && run ${name1} ${name2} + + rm ${name}_lookahead.c + rm ${name}_no_lookahead.c + rm ${name}_notags.c + rm ${name} +} + +verify() { + name1="$1" + name2="$2" + name=${name1}_${name2} + input="../gen/${name1}.dat.short" + output="${name1}.dat.short" + + [ -e ${input} ] || { echo "*** no input file ***"; exit 1; } + [ -e ${re2c} ] || { echo "*** no re2c ***"; exit 1; } + + ${re2c} -W ${name}.re -o ${name}_lookahead.c + ${re2c} --no-lookahead -W ${name}.re -o ${name}_no_lookahead.c + ${re2c} -W ${name}_notags.re -o ${name}_notags.c + + g++ -Wall -O2 -DVERIFY ${name}_lookahead.c -o${name} && ./${name} ${input} > ${output} && diff -q ${input} ${output} || echo "lookahead failed" + g++ -Wall -O2 -DVERIFY ${name}_no_lookahead.c -o${name} && ./${name} ${input} > ${output} && diff -q ${input} ${output} || echo "non-lookahead failed" + g++ -Wall -O2 -DVERIFY ${name}_notags.c -o${name} && ./${name} ${input} > ${output} && diff -q ${input} ${output} || echo "notags failed" + + rm ${name}_lookahead.c + rm ${name}_no_lookahead.c + rm ${name}_notags.c + rm ${name} + rm ${output} +} diff --git a/re2c/benchmarks/__run.sh b/re2c/benchmarks/__run.sh new file mode 100755 index 00000000..9f261da3 --- /dev/null +++ b/re2c/benchmarks/__run.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + +bench() { + cd "$1/$2/" + +# ./__verify.sh + + # warmup + ./__bench.sh 1> log.warmup 2>&1 + + ./__bench.sh 1> log._ 2>&1 + ./__bench_unopt.sh 1> log.unopt 2>&1 + ./__bench_b.sh 1> log.b 2>&1 + + cd ../.. +} + +bench http rfc7230 +bench http simple +bench uri rfc3986 +bench uri simple + diff --git a/re2c/benchmarks/http/rfc7230/__bench.sh b/re2c/benchmarks/http/rfc7230/__bench.sh new file mode 100755 index 00000000..8cf431d8 --- /dev/null +++ b/re2c/benchmarks/http/rfc7230/__bench.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile http rfc7230 "" +run_all http rfc7230 + diff --git a/re2c/benchmarks/http/rfc7230/__bench_b.sh b/re2c/benchmarks/http/rfc7230/__bench_b.sh new file mode 100755 index 00000000..9c203132 --- /dev/null +++ b/re2c/benchmarks/http/rfc7230/__bench_b.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile http rfc7230 "-b" +run_all http rfc7230 + diff --git a/re2c/benchmarks/http/rfc7230/__bench_unopt.sh b/re2c/benchmarks/http/rfc7230/__bench_unopt.sh new file mode 100755 index 00000000..fb74cb72 --- /dev/null +++ b/re2c/benchmarks/http/rfc7230/__bench_unopt.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile http rfc7230 "--no-optimize-tags" +run_all http rfc7230 + diff --git a/re2c/benchmarks/http/rfc7230/__verify.sh b/re2c/benchmarks/http/rfc7230/__verify.sh new file mode 100755 index 00000000..046c495b --- /dev/null +++ b/re2c/benchmarks/http/rfc7230/__verify.sh @@ -0,0 +1,4 @@ + +. ../../__bench_utils.sh + +verify http rfc7230 diff --git a/re2c/benchmarks/http/simple/__bench.sh b/re2c/benchmarks/http/simple/__bench.sh new file mode 100755 index 00000000..f4802e3f --- /dev/null +++ b/re2c/benchmarks/http/simple/__bench.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile http simple "" +run_all http simple + diff --git a/re2c/benchmarks/http/simple/__bench_b.sh b/re2c/benchmarks/http/simple/__bench_b.sh new file mode 100755 index 00000000..0a2747d0 --- /dev/null +++ b/re2c/benchmarks/http/simple/__bench_b.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile http simple "-b" +run_all http simple + diff --git a/re2c/benchmarks/http/simple/__bench_unopt.sh b/re2c/benchmarks/http/simple/__bench_unopt.sh new file mode 100755 index 00000000..b29e270c --- /dev/null +++ b/re2c/benchmarks/http/simple/__bench_unopt.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile http simple "--no-optimize-tags" +run_all http simple + diff --git a/re2c/benchmarks/http/simple/__verify.sh b/re2c/benchmarks/http/simple/__verify.sh new file mode 100755 index 00000000..bd31ed74 --- /dev/null +++ b/re2c/benchmarks/http/simple/__verify.sh @@ -0,0 +1,4 @@ + +. ../../__bench_utils.sh + +verify http simple diff --git a/re2c/benchmarks/uri/rfc3986/__bench.sh b/re2c/benchmarks/uri/rfc3986/__bench.sh new file mode 100755 index 00000000..3c237adb --- /dev/null +++ b/re2c/benchmarks/uri/rfc3986/__bench.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile uri rfc3986 "" +run_all uri rfc3986 + diff --git a/re2c/benchmarks/uri/rfc3986/__bench_b.sh b/re2c/benchmarks/uri/rfc3986/__bench_b.sh new file mode 100755 index 00000000..c8599cd4 --- /dev/null +++ b/re2c/benchmarks/uri/rfc3986/__bench_b.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile uri rfc3986 "-b" +run_all uri rfc3986 + diff --git a/re2c/benchmarks/uri/rfc3986/__bench_unopt.sh b/re2c/benchmarks/uri/rfc3986/__bench_unopt.sh new file mode 100755 index 00000000..726b9f3c --- /dev/null +++ b/re2c/benchmarks/uri/rfc3986/__bench_unopt.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile uri rfc3986 "--no-optimize-tags" +run_all uri rfc3986 + diff --git a/re2c/benchmarks/uri/rfc3986/__verify.sh b/re2c/benchmarks/uri/rfc3986/__verify.sh new file mode 100755 index 00000000..4e1844f7 --- /dev/null +++ b/re2c/benchmarks/uri/rfc3986/__verify.sh @@ -0,0 +1,4 @@ + +. ../../__bench_utils.sh + +verify uri rfc3986 diff --git a/re2c/benchmarks/uri/simple/__bench.sh b/re2c/benchmarks/uri/simple/__bench.sh new file mode 100755 index 00000000..e7a72580 --- /dev/null +++ b/re2c/benchmarks/uri/simple/__bench.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile uri simple "" +run_all uri simple + diff --git a/re2c/benchmarks/uri/simple/__bench_b.sh b/re2c/benchmarks/uri/simple/__bench_b.sh new file mode 100755 index 00000000..89e7200b --- /dev/null +++ b/re2c/benchmarks/uri/simple/__bench_b.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile uri simple "-b" +run_all uri simple + diff --git a/re2c/benchmarks/uri/simple/__bench_unopt.sh b/re2c/benchmarks/uri/simple/__bench_unopt.sh new file mode 100755 index 00000000..b4cdcfed --- /dev/null +++ b/re2c/benchmarks/uri/simple/__bench_unopt.sh @@ -0,0 +1,6 @@ + +. ../../__bench_utils.sh + +compile uri simple "--no-optimize-tags" +run_all uri simple + diff --git a/re2c/benchmarks/uri/simple/__verify.sh b/re2c/benchmarks/uri/simple/__verify.sh new file mode 100755 index 00000000..9fcbd97a --- /dev/null +++ b/re2c/benchmarks/uri/simple/__verify.sh @@ -0,0 +1,4 @@ + +. ../../__bench_utils.sh + +verify uri simple