]>
Commit | Line | Data |
---|---|---|
6962bb3d | 1 | #!/bin/bash |
0cfc9d65 NW |
2 | set -u |
3 | ||
6962bb3d | 4 | |
51c8c56b | 5 | DATADIR=./benchmark-datadir |
c66c731a JG |
6 | SHA256CMD="$(command -v sha256sum || echo shasum)" |
7 | SHA256ARGS="$(command -v sha256sum >/dev/null || echo '-a 256')" | |
51c8c56b | 8 | |
6962bb3d | 9 | function zcash_rpc { |
5a027a4a | 10 | ./src/zcash-cli -datadir="$DATADIR" -rpcuser=user -rpcpassword=password -rpcport=5983 "$@" |
6962bb3d TH |
11 | } |
12 | ||
338ff457 JG |
13 | function zcash_rpc_slow { |
14 | # Timeout of 1 hour | |
4e476986 | 15 | zcash_rpc -rpcclienttimeout=3600 "$@" |
338ff457 JG |
16 | } |
17 | ||
18 | function zcash_rpc_veryslow { | |
19 | # Timeout of 2.5 hours | |
4e476986 | 20 | zcash_rpc -rpcclienttimeout=9000 "$@" |
338ff457 JG |
21 | } |
22 | ||
5a027a4a NW |
23 | function zcash_rpc_wait_for_start { |
24 | zcash_rpc -rpcwait getinfo > /dev/null | |
25 | } | |
26 | ||
f5edc37f JG |
27 | function zcashd_generate { |
28 | zcash_rpc generate 101 > /dev/null | |
29 | } | |
30 | ||
6962bb3d | 31 | function zcashd_start { |
51c8c56b | 32 | rm -rf "$DATADIR" |
c66c731a | 33 | mkdir -p "$DATADIR/regtest" |
336fa630 | 34 | touch "$DATADIR/zcash.conf" |
dfe29d59 | 35 | ./src/zcashd -regtest -datadir="$DATADIR" -rpcuser=user -rpcpassword=password -rpcport=5983 -showmetrics=0 & |
6962bb3d | 36 | ZCASHD_PID=$! |
5a027a4a | 37 | zcash_rpc_wait_for_start |
6962bb3d TH |
38 | } |
39 | ||
40 | function zcashd_stop { | |
41 | zcash_rpc stop > /dev/null | |
453c7474 | 42 | wait $ZCASHD_PID |
6962bb3d TH |
43 | } |
44 | ||
45 | function zcashd_massif_start { | |
51c8c56b | 46 | rm -rf "$DATADIR" |
c66c731a | 47 | mkdir -p "$DATADIR/regtest" |
336fa630 | 48 | touch "$DATADIR/zcash.conf" |
6962bb3d | 49 | rm -f massif.out |
dfe29d59 | 50 | valgrind --tool=massif --time-unit=ms --massif-out-file=massif.out ./src/zcashd -regtest -datadir="$DATADIR" -rpcuser=user -rpcpassword=password -rpcport=5983 -showmetrics=0 & |
6962bb3d | 51 | ZCASHD_PID=$! |
5a027a4a | 52 | zcash_rpc_wait_for_start |
6962bb3d TH |
53 | } |
54 | ||
55 | function zcashd_massif_stop { | |
56 | zcash_rpc stop > /dev/null | |
57 | wait $ZCASHD_PID | |
58 | ms_print massif.out | |
59 | } | |
60 | ||
d578de8e TH |
61 | function zcashd_valgrind_start { |
62 | rm -rf "$DATADIR" | |
c66c731a | 63 | mkdir -p "$DATADIR/regtest" |
336fa630 | 64 | touch "$DATADIR/zcash.conf" |
d578de8e | 65 | rm -f valgrind.out |
dfe29d59 | 66 | valgrind --leak-check=yes -v --error-limit=no --log-file="valgrind.out" ./src/zcashd -regtest -datadir="$DATADIR" -rpcuser=user -rpcpassword=password -rpcport=5983 -showmetrics=0 & |
d578de8e | 67 | ZCASHD_PID=$! |
5a027a4a | 68 | zcash_rpc_wait_for_start |
d578de8e TH |
69 | } |
70 | ||
71 | function zcashd_valgrind_stop { | |
72 | zcash_rpc stop > /dev/null | |
73 | wait $ZCASHD_PID | |
74 | cat valgrind.out | |
75 | } | |
76 | ||
c66c731a | 77 | function extract_benchmark_data { |
08dc7889 | 78 | if [ -f "block-107134.tar.xz" ]; then |
c66c731a JG |
79 | # Check the hash of the archive: |
80 | "$SHA256CMD" $SHA256ARGS -c <<EOF | |
08dc7889 | 81 | 4bd5ad1149714394e8895fa536725ed5d6c32c99812b962bfa73f03b5ffad4bb block-107134.tar.xz |
c66c731a JG |
82 | EOF |
83 | ARCHIVE_RESULT=$? | |
84 | else | |
08dc7889 | 85 | echo "block-107134.tar.xz not found." |
c66c731a JG |
86 | ARCHIVE_RESULT=1 |
87 | fi | |
88 | if [ $ARCHIVE_RESULT -ne 0 ]; then | |
89 | zcashd_stop | |
90 | echo | |
91 | echo "Please generate it using qa/zcash/create_benchmark_archive.py" | |
92 | echo "and place it in the base directory of the repository." | |
93 | echo "Usage details are inside the Python script." | |
94 | exit 1 | |
95 | fi | |
08dc7889 | 96 | xzcat block-107134.tar.xz | tar x -C "$DATADIR/regtest" |
c66c731a JG |
97 | } |
98 | ||
1737627c SB |
99 | # Precomputation |
100 | case "$1" in | |
101 | *) | |
102 | case "$2" in | |
88b7f3c2 | 103 | verifyjoinsplit) |
1737627c SB |
104 | zcashd_start |
105 | RAWJOINSPLIT=$(zcash_rpc zcsamplejoinsplit) | |
106 | zcashd_stop | |
107 | esac | |
108 | esac | |
109 | ||
36b1269b TH |
110 | case "$1" in |
111 | time) | |
112 | zcashd_start | |
113 | case "$2" in | |
114 | sleep) | |
115 | zcash_rpc zcbenchmark sleep 10 | |
116 | ;; | |
117 | parameterloading) | |
118 | zcash_rpc zcbenchmark parameterloading 10 | |
119 | ;; | |
120 | createjoinsplit) | |
4082dcb1 | 121 | zcash_rpc zcbenchmark createjoinsplit 10 "${@:3}" |
36b1269b TH |
122 | ;; |
123 | verifyjoinsplit) | |
f7478de6 | 124 | zcash_rpc zcbenchmark verifyjoinsplit 1000 "\"$RAWJOINSPLIT\"" |
36b1269b TH |
125 | ;; |
126 | solveequihash) | |
338ff457 | 127 | zcash_rpc_slow zcbenchmark solveequihash 50 "${@:3}" |
36b1269b TH |
128 | ;; |
129 | verifyequihash) | |
130 | zcash_rpc zcbenchmark verifyequihash 1000 | |
131 | ;; | |
f5edc37f | 132 | validatelargetx) |
9c45b501 | 133 | zcash_rpc zcbenchmark validatelargetx 5 |
f5edc37f | 134 | ;; |
0fbab55b | 135 | trydecryptnotes) |
88b7f3c2 | 136 | zcash_rpc zcbenchmark trydecryptnotes 1000 "${@:3}" |
0fbab55b | 137 | ;; |
0bb3d40f JG |
138 | incnotewitnesses) |
139 | zcash_rpc zcbenchmark incnotewitnesses 100 "${@:3}" | |
140 | ;; | |
c66c731a JG |
141 | connectblockslow) |
142 | extract_benchmark_data | |
143 | zcash_rpc zcbenchmark connectblockslow 10 | |
144 | ;; | |
36b1269b TH |
145 | *) |
146 | zcashd_stop | |
147 | echo "Bad arguments." | |
148 | exit 1 | |
149 | esac | |
150 | zcashd_stop | |
151 | ;; | |
152 | memory) | |
9c45b501 | 153 | zcashd_massif_start |
36b1269b TH |
154 | case "$2" in |
155 | sleep) | |
156 | zcash_rpc zcbenchmark sleep 1 | |
157 | ;; | |
158 | parameterloading) | |
159 | zcash_rpc zcbenchmark parameterloading 1 | |
160 | ;; | |
161 | createjoinsplit) | |
338ff457 | 162 | zcash_rpc_slow zcbenchmark createjoinsplit 1 "${@:3}" |
36b1269b TH |
163 | ;; |
164 | verifyjoinsplit) | |
f7478de6 | 165 | zcash_rpc zcbenchmark verifyjoinsplit 1 "\"$RAWJOINSPLIT\"" |
36b1269b TH |
166 | ;; |
167 | solveequihash) | |
338ff457 | 168 | zcash_rpc_slow zcbenchmark solveequihash 1 "${@:3}" |
36b1269b TH |
169 | ;; |
170 | verifyequihash) | |
171 | zcash_rpc zcbenchmark verifyequihash 1 | |
172 | ;; | |
0fbab55b | 173 | trydecryptnotes) |
88b7f3c2 | 174 | zcash_rpc zcbenchmark trydecryptnotes 1 "${@:3}" |
0fbab55b | 175 | ;; |
0bb3d40f JG |
176 | incnotewitnesses) |
177 | zcash_rpc zcbenchmark incnotewitnesses 1 "${@:3}" | |
178 | ;; | |
c66c731a JG |
179 | connectblockslow) |
180 | extract_benchmark_data | |
181 | zcash_rpc zcbenchmark connectblockslow 1 | |
182 | ;; | |
36b1269b TH |
183 | *) |
184 | zcashd_massif_stop | |
185 | echo "Bad arguments." | |
186 | exit 1 | |
187 | esac | |
188 | zcashd_massif_stop | |
189 | rm -f massif.out | |
190 | ;; | |
d578de8e | 191 | valgrind) |
9c45b501 | 192 | zcashd_valgrind_start |
d578de8e TH |
193 | case "$2" in |
194 | sleep) | |
195 | zcash_rpc zcbenchmark sleep 1 | |
196 | ;; | |
197 | parameterloading) | |
198 | zcash_rpc zcbenchmark parameterloading 1 | |
199 | ;; | |
200 | createjoinsplit) | |
338ff457 | 201 | zcash_rpc_veryslow zcbenchmark createjoinsplit 1 "${@:3}" |
d578de8e TH |
202 | ;; |
203 | verifyjoinsplit) | |
f7478de6 | 204 | zcash_rpc zcbenchmark verifyjoinsplit 1 "\"$RAWJOINSPLIT\"" |
d578de8e TH |
205 | ;; |
206 | solveequihash) | |
338ff457 | 207 | zcash_rpc_veryslow zcbenchmark solveequihash 1 "${@:3}" |
d578de8e TH |
208 | ;; |
209 | verifyequihash) | |
210 | zcash_rpc zcbenchmark verifyequihash 1 | |
211 | ;; | |
0fbab55b | 212 | trydecryptnotes) |
88b7f3c2 | 213 | zcash_rpc zcbenchmark trydecryptnotes 1 "${@:3}" |
0fbab55b | 214 | ;; |
0bb3d40f JG |
215 | incnotewitnesses) |
216 | zcash_rpc zcbenchmark incnotewitnesses 1 "${@:3}" | |
217 | ;; | |
c66c731a JG |
218 | connectblockslow) |
219 | extract_benchmark_data | |
220 | zcash_rpc zcbenchmark connectblockslow 1 | |
221 | ;; | |
d578de8e TH |
222 | *) |
223 | zcashd_valgrind_stop | |
224 | echo "Bad arguments." | |
225 | exit 1 | |
226 | esac | |
227 | zcashd_valgrind_stop | |
228 | rm -f valgrind.out | |
229 | ;; | |
88325d8a TH |
230 | valgrind-tests) |
231 | case "$2" in | |
232 | gtest) | |
233 | rm -f valgrind.out | |
234 | valgrind --leak-check=yes -v --error-limit=no --log-file="valgrind.out" ./src/zcash-gtest | |
235 | cat valgrind.out | |
236 | rm -f valgrind.out | |
237 | ;; | |
238 | test_bitcoin) | |
239 | rm -f valgrind.out | |
240 | valgrind --leak-check=yes -v --error-limit=no --log-file="valgrind.out" ./src/test/test_bitcoin | |
241 | cat valgrind.out | |
242 | rm -f valgrind.out | |
243 | ;; | |
244 | *) | |
245 | echo "Bad arguments." | |
246 | exit 1 | |
247 | esac | |
248 | ;; | |
36b1269b TH |
249 | *) |
250 | echo "Bad arguments." | |
251 | exit 1 | |
252 | esac | |
a0be8e26 | 253 | |
51c8c56b | 254 | # Cleanup |
51c8c56b | 255 | rm -rf "$DATADIR" |