-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench
executable file
·80 lines (70 loc) · 1.72 KB
/
bench
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
# Usage: bench [all|b0|ocamlbuild|jbuilder|dirty|clean]
set -e
JOBS=${JOBS:=4}
INCR_FILE=src-std/b0_string.ml
start_cold () { printf "\n$1 [cold build]"; }
start_zero () { printf "\n$1 [zero rebuild]"; }
start_incr ()
{
printf "\n$1 [incr rebuild]";
# make sure the file is clean
if git diff --exit-code $INCR_FILE > /dev/null; then
printf "\n;;" >> $INCR_FILE
else
printf "\n\nERROR: $INCR_FILE: dirty file, can't test incr. Bye.\n";
exit 1
fi
}
end_incr () { git checkout $INCR_FILE; }
time_b0 () { time (./b0 -q -j $JOBS &> /dev/null); }
run_b0 ()
{
rm -rf _b0
start_cold "b0"; time_b0
start_zero "b0"; time_b0
start_incr "b0"; time_b0; end_incr
}
time_ocamlbuild () { time (./pkg/pkg.ml build -q --jobs $JOBS &> /dev/null); }
run_ocamlbuild ()
{
rm -rf _build
start_cold "ocamlbuild"; time_ocamlbuild;
start_zero "ocamlbuild"; time_ocamlbuild;
start_incr "ocamlbuild"; time_ocamlbuild; end_incr
}
time_jbuilder () { time (jbuilder build -j $JOBS $JB_TARGETS &> /dev/null); }
run_jbuilder ()
{
JB_TARGETS="@install src-exe/bzero.bc"
rm -rf _build
start_cold "jbuilder"; time_jbuilder;
start_zero "jbuilder"; time_jbuilder;
start_incr "jbuilder"; time_jbuilder; end_incr
}
clean ()
{
rm -rf _build _b0
rm src-*/.merlin # jbuilder poops
}
action ()
{
case $1 in
all)
# The order is important here since we currently bootstrap
# b0 from ocamlbuild
run_ocamlbuild
run_b0
run_jbuilder
;;
ocamlbuild) run_ocamlbuild;;
jbuilder) run_jbuilder;;
b0) run_b0;;
dirty) start_incr "Dirty $INCR_FILE";;
clean) clean;;
*) echo "No such command: $1";;
esac
}
if [ $# -eq 0 ];
then action all;
else action $*; fi