raz / src / bench.sh

25 lines · 1.0 KiB · executable · raw · history · last change 84f97627

1#!/bin/sh
2# The compiler's speed against the previous release's, the one BOOT
3# names (build/boot/raz), on the same generated program: the best of
4# five runs of each, as build/cmp/raz, which finds the library beside
5# it. A regression test: it fails if this compiler takes more than a
6# tenth longer. Run from the repository root, after make raz.
7set -e
8mkdir -p build/cmp/bench
9ln -sfn ../../lib build/cmp/lib
10sh test/genbench.sh 12000 >build/cmp/bench/Bench.raz
11echo "$(($(wc -l <build/cmp/bench/Bench.raz))) lines"
12for t in prev this; do
13 if [ $t = prev ]; then cp build/boot/raz build/cmp/raz; else cp raz build/cmp/raz; fi
14 best=0
15 for i in 1 2 3 4 5; do
16 s=$(sh test/nanos.sh); build/cmp/raz -o build/cmp/bench/Bench.$t build/cmp/bench/Bench.raz; e=$(sh test/nanos.sh)
17 d=$(( (e - s) / 1000000 )); if [ $best = 0 ] || [ $d -lt $best ]; then best=$d; fi
18 done
19 echo "$t: $best ms"
20 eval "ms_$t=$best"
21done
22if [ $((ms_this * 10)) -gt $((ms_prev * 11)) ]; then
23 echo "slower than the previous release, $(cut -d" " -f1 BOOT), by more than a tenth"
24 exit 1
25fi