]> granicus.if.org Git - re2c/commitdiff
Added scripts that run benchmarks.
authorUlya Trofimovich <skvadrik@gmail.com>
Wed, 2 Aug 2017 14:49:07 +0000 (15:49 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Wed, 2 Aug 2017 15:06:32 +0000 (16:06 +0100)
18 files changed:
re2c/benchmarks/__bench_utils.sh [new file with mode: 0644]
re2c/benchmarks/__run.sh [new file with mode: 0755]
re2c/benchmarks/http/rfc7230/__bench.sh [new file with mode: 0755]
re2c/benchmarks/http/rfc7230/__bench_b.sh [new file with mode: 0755]
re2c/benchmarks/http/rfc7230/__bench_unopt.sh [new file with mode: 0755]
re2c/benchmarks/http/rfc7230/__verify.sh [new file with mode: 0755]
re2c/benchmarks/http/simple/__bench.sh [new file with mode: 0755]
re2c/benchmarks/http/simple/__bench_b.sh [new file with mode: 0755]
re2c/benchmarks/http/simple/__bench_unopt.sh [new file with mode: 0755]
re2c/benchmarks/http/simple/__verify.sh [new file with mode: 0755]
re2c/benchmarks/uri/rfc3986/__bench.sh [new file with mode: 0755]
re2c/benchmarks/uri/rfc3986/__bench_b.sh [new file with mode: 0755]
re2c/benchmarks/uri/rfc3986/__bench_unopt.sh [new file with mode: 0755]
re2c/benchmarks/uri/rfc3986/__verify.sh [new file with mode: 0755]
re2c/benchmarks/uri/simple/__bench.sh [new file with mode: 0755]
re2c/benchmarks/uri/simple/__bench_b.sh [new file with mode: 0755]
re2c/benchmarks/uri/simple/__bench_unopt.sh [new file with mode: 0755]
re2c/benchmarks/uri/simple/__verify.sh [new file with mode: 0755]

diff --git a/re2c/benchmarks/__bench_utils.sh b/re2c/benchmarks/__bench_utils.sh
new file mode 100644 (file)
index 0000000..fda5495
--- /dev/null
@@ -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 (executable)
index 0000000..9f261da
--- /dev/null
@@ -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 (executable)
index 0000000..8cf431d
--- /dev/null
@@ -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 (executable)
index 0000000..9c20313
--- /dev/null
@@ -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 (executable)
index 0000000..fb74cb7
--- /dev/null
@@ -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 (executable)
index 0000000..046c495
--- /dev/null
@@ -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 (executable)
index 0000000..f4802e3
--- /dev/null
@@ -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 (executable)
index 0000000..0a2747d
--- /dev/null
@@ -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 (executable)
index 0000000..b29e270
--- /dev/null
@@ -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 (executable)
index 0000000..bd31ed7
--- /dev/null
@@ -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 (executable)
index 0000000..3c237ad
--- /dev/null
@@ -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 (executable)
index 0000000..c8599cd
--- /dev/null
@@ -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 (executable)
index 0000000..726b9f3
--- /dev/null
@@ -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 (executable)
index 0000000..4e1844f
--- /dev/null
@@ -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 (executable)
index 0000000..e7a7258
--- /dev/null
@@ -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 (executable)
index 0000000..89e7200
--- /dev/null
@@ -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 (executable)
index 0000000..b4cdcfe
--- /dev/null
@@ -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 (executable)
index 0000000..9fcbd97
--- /dev/null
@@ -0,0 +1,4 @@
+
+. ../../__bench_utils.sh
+
+verify uri simple