-
Notifications
You must be signed in to change notification settings - Fork 6
/
benchmark.sh
executable file
·74 lines (68 loc) · 1.58 KB
/
benchmark.sh
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
#!/usr/bin/env zsh
function buildBench() {
tmpi=""
isep=""
for i in a b c d e f g h i j ; do
tmpj=""
jsep=""
for j in a b c d e f g h i j ; do
tmpk=""
ksep=""
for k in a b c d e f g h i j ; do
tmpl=""
lsep=""
for l in a b c d e f g h i j ; do
echo "det $i$j$k$l() :- <$(((RANDOM%999 + 1)/1000.0)),$(((RANDOM%999 + 1)/1000.0))>."
tmpl="$tmpl $lsep $i$j$k$l"
lsep=","
done
echo "nondet $i$j$k() :- $tmpl ."
tmpk="$tmpk $ksep $i$j$k"
ksep=","
done
echo "nondet $i$j() :- $tmpk ."
tmpj="$tmpj $jsep $i$j"
jsep=","
done
echo "nondet $i() :- $tmpj ."
tmpi="$tmpi $isep $i"
isep=","
done
echo "nondet bench() :- $tmpi ."
}
time (buildBench > bench.myc)
echo "Created benchmark"
export TIME="+%e"
i=0
ax=0
while [[ $i -lt 10 ]] ; do
tmpTime=$( ( (time (./mycroft.lua -t bench.myc > /dev/null)) 2>&1 ) | sed 's/^.* \([0-9.][0-9.]*\) total.*$/\1/' )
ax=$((ax+tmpTime))
i=$((i+1))
echo -e ".\c"
done
echo
timeOff=$((ax/i))
echo "Offset for startup time: $timeOff"
echo "?- bench()." >> bench.myc
i=0
ax=0
while [[ $i -lt 10 ]] ; do
tmpTime=$( ( (time (./mycroft.lua -t bench.myc > /dev/null)) 2>&1 ) | sed 's/^.* \([0-9.][0-9.]*\) total.*$/\1/' )
ax=$((ax+tmpTime))
i=$((i+1))
echo -e ".\c"
done
avg=$((ax/i))
echo "Average execution time: $avg"
avg=$((avg-timeOff))
echo "Average adjusted execution time: $avg"
avg=$(((10**4)/avg))
if [[ $(echo $avg | cut -d. -f 1) -gt 1000 ]] ; then
if [[ $(echo $avg | cut -d. -f 1) -gt 1000000 ]] ; then
avg=$((avg/1000000))M
else
avg=$((avg/1000))K
fi
fi
echo "Benchmark: ${avg}LIPS"