-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-correctness.sh
executable file
·123 lines (107 loc) · 2.5 KB
/
test-correctness.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env bash
set -e
function mytime ()
{
if type -p gtime > /dev/null; then
gtime "$@";
else
/usr/bin/time "$@";
fi
}
function mysort ()
{
if type -p gsort > /dev/null; then
gsort "$@";
else
sort "$@";
fi
}
function testone () {
timing=$(mktemp)
cmd="$1"
name="$2"
maxdist="$3"
extra="$4"
inputfn="sample-data/${name}.input"
expectedfn="sample-data/${name}.${maxdist}.output"
echo "=== cmd='$cmd' name=$name maxdist=$maxdist"
mytime -f "wall=%es user=%Us" -o "$timing" $cmd "$inputfn" "$maxdist" $extra | mysort -n -b -k 1,1 -k 2,2 -k 3,3 >out
if test -f "$expectedfn"; then
if cmp -s "$expectedfn" out; then
t=$(cat "$timing")
echo " pass $t"
rm out
else
diff -u "$expectedfn" out
exit 1
fi
else
echo "The file $expectedfn is missing. Will use output"
mv out $expectedfn
fi
rm "$timing"
}
function testpython () {
testone "./python-simple/find-similar.py" "$1" "$2"
}
function testc () {
testone "c-simple/find-similar-gcc_O3" "$1" "$2"
testone "c-unroll/find-similar-gcc_O3" "$1" "$2"
testone "c-unroll2/find-similar-gcc_O3" "$1" "$2" 128
if [[ $1 == "64_"* ]]; then
testone "c-metric-tree/find-similar-gcc_O3" "$1" "$2" 64
fi
testone "c-parallel/find-similar-gcc_O3" "$1" "$2" 4
}
function testjava () {
testone "java -cp java-simple FindSimilar " "$1" "$2"
}
#### Java
if true; then
testjava 64_test_01 1
testjava 64_test_01 2
testjava 64_test_01 3
testjava 256_test_01 1
testjava 256_test_01 2
testjava 256_test_01 3
testjava 64_1k 15
testjava 256_1k 100
testjava 64_10k 15
testjava 256_10k 98
testjava 64_100k 13
testjava 256_100k 87
# testjava 64_1m 10
# testjava 256_1m 100
fi
#### C
if true; then
testc 64_test_01 1
testc 64_test_01 2
testc 64_test_01 3
testc 256_test_01 1
testc 256_test_01 2
testc 256_test_01 3
testc 64_1k 15
testc 256_1k 100
testc 64_10k 15
testc 256_10k 98
testc 64_100k 13
testc 256_100k 87
# testc 64_1m 10
# testc 256_1m 83
fi
#### Python
if true; then
testpython 64_test_01 1
testpython 64_test_01 2
testpython 64_test_01 3
testpython 256_test_01 1
testpython 256_test_01 2
testpython 256_test_01 3
fi
if true; then
testpython 64_1k 15
testpython 64_10k 15
testpython 256_1k 100
testpython 256_10k 98
fi