-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest1.sh
executable file
·108 lines (101 loc) · 2.5 KB
/
test1.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
#!/bin/sh
if [ -z "$CFLAGS" ]; then
CFLAGS="-g -march=native -fno-strict-aliasing -Wall -Wextra"
else
make clean
fi
usage() {
echo "Usage: $0 [-bdfIMpsvx] [-a alg] [-h hash] [-S size] [-m mapfile] [-c num]" 1>&2;
exit 1;
}
alg=chm
WORDS=/usr/share/dict/words
IN=_words1000
hashc=mi_vector_hash.c
while getopts "a:h:S:c:m:bdIMfpsvx" o; do
case "$o" in
a) alg=$OPTARG
if [ $alg != chm -a $alg != chm3 -a $alg != bdz -a $alg != bpz ]; then
echo Invalid -a $alg
usage
fi
if [ $alg = bpz ]; then
alg=bdz
fi
;;
b) big=1 ;;
f) opts="$opts -f" ;;
h) hash=$OPTARG
opts="$opts -h $hash"
if [ x$hash != xmi_vector_hash ]; then unset hashc; fi
;;
c) opts="$opts -c $OPTARG" ;;
d) opts="$opts -d"
copts="-D_DATA $copts"
;;
I) intkeys=1
unset hashc
opts="$opts -I"
copts="-D_INTKEYS $copts"
;;
m) mapfile=$OPTARG ;;
M) opts="$opts -M" ;;
p) opts="$opts -p" ;;
s) opts="$opts -s" ;;
S) size=$OPTARG ;;
v) v="-v" ;;
x) intkeys=1
unset hashc
opts="$opts -I"
copts="-D_INTKEYS $copts"
hex=1
;;
*) usage ;;
esac
done
shift $((OPTIND-1))
out=$alg
if [ -n "$intkeys" ]; then
[ -z $hash ] || usage
if [ -n "$hex" ]; then
IN=_randhex
out=inthex${alg}
elif [ -n "$big" ]; then
IN=_randbig
out=intbig${alg}
else
IN=_rand100
out=int${alg}
fi
if [ -n "$size" ]; then
IN=_rand${size}
seq $(( $size * 2 )) | random > ${IN}
fi
else
if [ -n "$big" ]; then
IN=_words
out=big${alg}
fi
if [ -n "$size" ]; then
IN=_words${size}
head -n ${size} <${WORDS} >$IN
fi
fi
copts="-D$alg $copts"
if [ -n "$mapfile" ]; then
opts="$opts -m $mapfile"
elif [ x$alg = xbdz ]; then
copts="$copts -D_NOMAP"
fi
if [ -n "$hash" ]; then
out="${out}_${hash}"
fi
echo make CFLAGS="\"${CFLAGS}\"" nbperf ${IN}
make CFLAGS="${CFLAGS}" nbperf ${IN}
test -e ${IN} || exit 1
echo ./nbperf $opts -a $alg -o _test_${out}.c $IN
./nbperf $opts -a $alg -o _test_${out}.c $IN
echo cc $CFLAGS -I. $copts _test_${out}.c test_main.c $hashc -o _test_${out}
cc $CFLAGS -I. $copts _test_${out}.c test_main.c $hashc -o _test_${out}
echo ./_test_${out} $v $IN
./_test_${out} $v $IN