forked from weidai11/cryptopp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-benchmarks.sh
executable file
·173 lines (145 loc) · 4.89 KB
/
make-benchmarks.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/usr/bin/env bash
#############################################################################
#
# The following builds the benchmarks under 5.6.2, 5.6.4 and Master. The
# results can then be compared to ensure an speed penalty is not inadvertently
# taken. Crypto++ 5.6.2 is significant because its the last version Wei worked
# on before turning the library over to the community.
#
# Written and placed in public domain by Jeffrey Walton.
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See https://www.cryptopp.com/wiki/Benchmarks for more details
#
#############################################################################
# Set to suite your taste. Speed is in GiHz
if [[ -z "$CPU_FREQ" ]]; then
if [[ ! -z "CRYPTOPP_CPU_SPEED" ]]; then
CPU_FREQ="$CRYPTOPP_CPU_SPEED"
else
CPU_FREQ=2.8
fi
fi
echo "***************************************************"
echo "Using CPU frequency of $CPU_FREQ GiHz."
echo "Please modify this script if its not correct"
echo
#############################################################################
current=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
git fetch --all &>/dev/null &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "$PWD does not appear to be a Git repository"
exit 1
fi
#############################################################################
# Try to find a fast option
OPT=
if [[ -z "$OPT" ]]; then
rm -f "$TMP/adhoc.exe" &>/dev/null
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O3 adhoc.cpp -o "$TMP/adhoc.exe" &>/dev/null
if [[ ("$?" -eq "0") ]]; then
OPT=-O3
fi
fi
if [[ -z "$OPT" ]]; then
rm -f "$TMP/adhoc.exe" &>/dev/null
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO3 adhoc.cpp -o "$TMP/adhoc.exe" &>/dev/null
if [[ ("$?" -eq "0") ]]; then
OPT=-xO3
fi
fi
if [[ -z "$OPT" ]]; then
rm -f "$TMP/adhoc.exe" &>/dev/null
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O2 adhoc.cpp -o "$TMP/adhoc.exe" &>/dev/null
if [[ ("$?" -eq "0") ]]; then
OPT=-O2
fi
fi
if [[ -z "$OPT" ]]; then
rm -f "$TMP/adhoc.exe" &>/dev/null
"$CXX" -DCRYPTOPP_ADHOC_MAIN -xO2 adhoc.cpp -o "$TMP/adhoc.exe" &>/dev/null
if [[ ("$?" -eq "0") ]]; then
OPT=-xO2
fi
fi
if [[ -z "$OPT" ]]; then
rm -f "$TMP/adhoc.exe" &>/dev/null
"$CXX" -DCRYPTOPP_ADHOC_MAIN -O adhoc.cpp -o "$TMP/adhoc.exe" &>/dev/null
if [[ ("$?" -eq "0") ]]; then
OPT=-O
fi
fi
#############################################################################
echo "***************************************************"
echo "**************** Crypto++ 5.6.2 *******************"
echo "***************************************************"
echo
git checkout -f CRYPTOPP_5_6_2 &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "git checkout CRYPTOPP_5_6_2 failed"
else
rm -f *.o benchmarks.html benchmarks-562.html &>/dev/null
CXXFLAGS="-DNDEBUG $OPT" make
if [[ "$?" -eq "0" ]]; then
echo "Running benchmarks for Crypto++ 5.6.2"
./cryptest.exe b 3 "$CPU_FREQ" > benchmarks-562.html
if [[ "$?" -ne "0" ]]; then
rm -rf benchmarks-562.html &>/dev/null
echo "Failed to create benchmarks for Crypto++ 5.6.2"
fi
else
echo "Failed to make benchmarks for Crypto++ 5.6.2"
fi
fi
#############################################################################
echo "***************************************************"
echo "**************** Crypto++ 5.6.4 *******************"
echo "***************************************************"
echo
git checkout -f CRYPTOPP_5_6_4 &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "git checkout CRYPTOPP_5_6_4 failed"
else
rm -f *.o benchmarks.html benchmarks-564.html &>/dev/null
CXXFLAGS="-DNDEBUG $OPT" make
if [[ "$?" -eq "0" ]]; then
echo "Running benchmarks for Crypto++ 5.6.4"
./cryptest.exe b 3 "$CPU_FREQ" > benchmarks-564.html
if [[ "$?" -ne "0" ]]; then
rm -rf benchmarks-564.html &>/dev/null
echo "Failed to create benchmarks for Crypto++ 5.6.4"
fi
else
echo "Failed to make benchmarks for Crypto++ 5.6.4"
fi
fi
#############################################################################
echo "***************************************************"
echo "*************** Crypto++ Master *******************"
echo "***************************************************"
echo
git checkout -f master &>/dev/null
if [[ "$?" -ne "0" ]]; then
echo "git checkout master failed"
else
rm -f *.o benchmarks.html benchmarks-master.html &>/dev/null
CXXFLAGS="-DNDEBUG $OPT" make
if [[ "$?" -eq "0" ]]; then
echo "Running benchmarks for Crypto++ Master"
./cryptest.exe b 3 "$CPU_FREQ" > benchmarks-master.html
if [[ "$?" -ne "0" ]]; then
rm -rf benchmarks-master.html &>/dev/null
echo "Failed to create benchmarks for Crypto++ Master"
fi
else
echo "Failed to make benchmarks for Crypto++ Master"
fi
fi
#############################################################################
if [[ ! -z "$current" ]]; then
git checkout -f "$current"
fi
exit 0