]> Git Repo - VerusCoin.git/blame - qa/zcash/performance-measurements.sh
Auto merge of #2463 - str4d:713-rollback-limit, r=str4d
[VerusCoin.git] / qa / zcash / performance-measurements.sh
CommitLineData
6962bb3d 1#!/bin/bash
0cfc9d65
NW
2set -u
3
6962bb3d 4
51c8c56b 5DATADIR=./benchmark-datadir
c66c731a
JG
6SHA256CMD="$(command -v sha256sum || echo shasum)"
7SHA256ARGS="$(command -v sha256sum >/dev/null || echo '-a 256')"
51c8c56b 8
6962bb3d 9function zcash_rpc {
5a027a4a 10 ./src/zcash-cli -datadir="$DATADIR" -rpcuser=user -rpcpassword=password -rpcport=5983 "$@"
6962bb3d
TH
11}
12
338ff457
JG
13function zcash_rpc_slow {
14 # Timeout of 1 hour
4e476986 15 zcash_rpc -rpcclienttimeout=3600 "$@"
338ff457
JG
16}
17
18function zcash_rpc_veryslow {
19 # Timeout of 2.5 hours
4e476986 20 zcash_rpc -rpcclienttimeout=9000 "$@"
338ff457
JG
21}
22
5a027a4a
NW
23function zcash_rpc_wait_for_start {
24 zcash_rpc -rpcwait getinfo > /dev/null
25}
26
f5edc37f
JG
27function zcashd_generate {
28 zcash_rpc generate 101 > /dev/null
29}
30
a76174b7
JG
31function extract_benchmark_datadir {
32 if [ -f "$1.tar.xz" ]; then
33 # Check the hash of the archive:
34 "$SHA256CMD" $SHA256ARGS -c <<EOF
35$2 $1.tar.xz
36EOF
37 ARCHIVE_RESULT=$?
38 else
39 echo "$1.tar.xz not found."
40 ARCHIVE_RESULT=1
41 fi
42 if [ $ARCHIVE_RESULT -ne 0 ]; then
43 zcashd_stop
44 echo
45 echo "Please download it and place it in the base directory of the repository."
46 exit 1
47 fi
48 xzcat "$1.tar.xz" | tar x
49}
50
51function use_200k_benchmark {
52 rm -rf benchmark-200k-UTXOs
53 extract_benchmark_datadir benchmark-200k-UTXOs dc8ab89eaa13730da57d9ac373c1f4e818a37181c1443f61fd11327e49fbcc5e
54 DATADIR="./benchmark-200k-UTXOs/node$1"
55}
56
6962bb3d 57function zcashd_start {
a76174b7 58 case "$1" in
99dd50c3 59 sendtoaddress|loadwallet|listunspent)
a76174b7
JG
60 case "$2" in
61 200k-recv)
62 use_200k_benchmark 0
63 ;;
64 200k-send)
65 use_200k_benchmark 1
66 ;;
67 *)
72b4f0b3 68 echo "Bad arguments to zcashd_start."
a76174b7
JG
69 exit 1
70 esac
71 ;;
72 *)
73 rm -rf "$DATADIR"
74 mkdir -p "$DATADIR/regtest"
75 touch "$DATADIR/zcash.conf"
76 esac
dfe29d59 77 ./src/zcashd -regtest -datadir="$DATADIR" -rpcuser=user -rpcpassword=password -rpcport=5983 -showmetrics=0 &
6962bb3d 78 ZCASHD_PID=$!
5a027a4a 79 zcash_rpc_wait_for_start
6962bb3d
TH
80}
81
82function zcashd_stop {
83 zcash_rpc stop > /dev/null
453c7474 84 wait $ZCASHD_PID
6962bb3d
TH
85}
86
87function zcashd_massif_start {
a76174b7 88 case "$1" in
99dd50c3 89 sendtoaddress|loadwallet|listunspent)
a76174b7
JG
90 case "$2" in
91 200k-recv)
92 use_200k_benchmark 0
93 ;;
94 200k-send)
95 use_200k_benchmark 1
96 ;;
97 *)
72b4f0b3 98 echo "Bad arguments to zcashd_massif_start."
a76174b7
JG
99 exit 1
100 esac
101 ;;
102 *)
103 rm -rf "$DATADIR"
104 mkdir -p "$DATADIR/regtest"
105 touch "$DATADIR/zcash.conf"
106 esac
6962bb3d 107 rm -f massif.out
dfe29d59 108 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 109 ZCASHD_PID=$!
5a027a4a 110 zcash_rpc_wait_for_start
6962bb3d
TH
111}
112
113function zcashd_massif_stop {
114 zcash_rpc stop > /dev/null
115 wait $ZCASHD_PID
116 ms_print massif.out
117}
118
d578de8e
TH
119function zcashd_valgrind_start {
120 rm -rf "$DATADIR"
c66c731a 121 mkdir -p "$DATADIR/regtest"
336fa630 122 touch "$DATADIR/zcash.conf"
d578de8e 123 rm -f valgrind.out
dfe29d59 124 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 125 ZCASHD_PID=$!
5a027a4a 126 zcash_rpc_wait_for_start
d578de8e
TH
127}
128
129function zcashd_valgrind_stop {
130 zcash_rpc stop > /dev/null
131 wait $ZCASHD_PID
132 cat valgrind.out
133}
134
c66c731a 135function extract_benchmark_data {
08dc7889 136 if [ -f "block-107134.tar.xz" ]; then
c66c731a
JG
137 # Check the hash of the archive:
138 "$SHA256CMD" $SHA256ARGS -c <<EOF
08dc7889 1394bd5ad1149714394e8895fa536725ed5d6c32c99812b962bfa73f03b5ffad4bb block-107134.tar.xz
c66c731a
JG
140EOF
141 ARCHIVE_RESULT=$?
142 else
08dc7889 143 echo "block-107134.tar.xz not found."
c66c731a
JG
144 ARCHIVE_RESULT=1
145 fi
146 if [ $ARCHIVE_RESULT -ne 0 ]; then
147 zcashd_stop
148 echo
149 echo "Please generate it using qa/zcash/create_benchmark_archive.py"
150 echo "and place it in the base directory of the repository."
151 echo "Usage details are inside the Python script."
152 exit 1
153 fi
08dc7889 154 xzcat block-107134.tar.xz | tar x -C "$DATADIR/regtest"
c66c731a
JG
155}
156
147fffb7
JDL
157
158if [ $# -lt 2 ]
159then
a20b975a 160 echo "$0 : At least two arguments are required!"
147fffb7
JDL
161 exit 1
162fi
163
1737627c
SB
164# Precomputation
165case "$1" in
166 *)
167 case "$2" in
88b7f3c2 168 verifyjoinsplit)
a76174b7 169 zcashd_start "${@:2}"
1737627c
SB
170 RAWJOINSPLIT=$(zcash_rpc zcsamplejoinsplit)
171 zcashd_stop
172 esac
173esac
174
36b1269b
TH
175case "$1" in
176 time)
a76174b7 177 zcashd_start "${@:2}"
36b1269b
TH
178 case "$2" in
179 sleep)
180 zcash_rpc zcbenchmark sleep 10
181 ;;
182 parameterloading)
183 zcash_rpc zcbenchmark parameterloading 10
184 ;;
185 createjoinsplit)
4082dcb1 186 zcash_rpc zcbenchmark createjoinsplit 10 "${@:3}"
36b1269b
TH
187 ;;
188 verifyjoinsplit)
f7478de6 189 zcash_rpc zcbenchmark verifyjoinsplit 1000 "\"$RAWJOINSPLIT\""
36b1269b
TH
190 ;;
191 solveequihash)
338ff457 192 zcash_rpc_slow zcbenchmark solveequihash 50 "${@:3}"
36b1269b
TH
193 ;;
194 verifyequihash)
195 zcash_rpc zcbenchmark verifyequihash 1000
196 ;;
f5edc37f 197 validatelargetx)
818b94f9 198 zcash_rpc zcbenchmark validatelargetx 10 "${@:3}"
f5edc37f 199 ;;
0fbab55b 200 trydecryptnotes)
88b7f3c2 201 zcash_rpc zcbenchmark trydecryptnotes 1000 "${@:3}"
0fbab55b 202 ;;
0bb3d40f
JG
203 incnotewitnesses)
204 zcash_rpc zcbenchmark incnotewitnesses 100 "${@:3}"
205 ;;
c66c731a
JG
206 connectblockslow)
207 extract_benchmark_data
208 zcash_rpc zcbenchmark connectblockslow 10
209 ;;
a76174b7
JG
210 sendtoaddress)
211 zcash_rpc zcbenchmark sendtoaddress 10 "${@:4}"
212 ;;
2e8aefdc
AG
213 loadwallet)
214 zcash_rpc zcbenchmark loadwallet 10
215 ;;
99dd50c3
JG
216 listunspent)
217 zcash_rpc zcbenchmark listunspent 10
218 ;;
36b1269b
TH
219 *)
220 zcashd_stop
72b4f0b3 221 echo "Bad arguments to time."
36b1269b
TH
222 exit 1
223 esac
224 zcashd_stop
225 ;;
226 memory)
a76174b7 227 zcashd_massif_start "${@:2}"
36b1269b
TH
228 case "$2" in
229 sleep)
230 zcash_rpc zcbenchmark sleep 1
231 ;;
232 parameterloading)
233 zcash_rpc zcbenchmark parameterloading 1
234 ;;
235 createjoinsplit)
338ff457 236 zcash_rpc_slow zcbenchmark createjoinsplit 1 "${@:3}"
36b1269b
TH
237 ;;
238 verifyjoinsplit)
f7478de6 239 zcash_rpc zcbenchmark verifyjoinsplit 1 "\"$RAWJOINSPLIT\""
36b1269b
TH
240 ;;
241 solveequihash)
338ff457 242 zcash_rpc_slow zcbenchmark solveequihash 1 "${@:3}"
36b1269b
TH
243 ;;
244 verifyequihash)
245 zcash_rpc zcbenchmark verifyequihash 1
246 ;;
94790c5d
JG
247 validatelargetx)
248 zcash_rpc zcbenchmark validatelargetx 1
249 ;;
0fbab55b 250 trydecryptnotes)
88b7f3c2 251 zcash_rpc zcbenchmark trydecryptnotes 1 "${@:3}"
0fbab55b 252 ;;
0bb3d40f
JG
253 incnotewitnesses)
254 zcash_rpc zcbenchmark incnotewitnesses 1 "${@:3}"
255 ;;
c66c731a
JG
256 connectblockslow)
257 extract_benchmark_data
258 zcash_rpc zcbenchmark connectblockslow 1
259 ;;
a76174b7
JG
260 sendtoaddress)
261 zcash_rpc zcbenchmark sendtoaddress 1 "${@:4}"
262 ;;
091c089d
JG
263 loadwallet)
264 # The initial load is sufficient for measurement
265 ;;
99dd50c3
JG
266 listunspent)
267 zcash_rpc zcbenchmark listunspent 1
268 ;;
36b1269b
TH
269 *)
270 zcashd_massif_stop
72b4f0b3 271 echo "Bad arguments to memory."
36b1269b
TH
272 exit 1
273 esac
274 zcashd_massif_stop
275 rm -f massif.out
276 ;;
d578de8e 277 valgrind)
9c45b501 278 zcashd_valgrind_start
d578de8e
TH
279 case "$2" in
280 sleep)
281 zcash_rpc zcbenchmark sleep 1
282 ;;
283 parameterloading)
284 zcash_rpc zcbenchmark parameterloading 1
285 ;;
286 createjoinsplit)
338ff457 287 zcash_rpc_veryslow zcbenchmark createjoinsplit 1 "${@:3}"
d578de8e
TH
288 ;;
289 verifyjoinsplit)
f7478de6 290 zcash_rpc zcbenchmark verifyjoinsplit 1 "\"$RAWJOINSPLIT\""
d578de8e
TH
291 ;;
292 solveequihash)
338ff457 293 zcash_rpc_veryslow zcbenchmark solveequihash 1 "${@:3}"
d578de8e
TH
294 ;;
295 verifyequihash)
296 zcash_rpc zcbenchmark verifyequihash 1
297 ;;
0fbab55b 298 trydecryptnotes)
88b7f3c2 299 zcash_rpc zcbenchmark trydecryptnotes 1 "${@:3}"
0fbab55b 300 ;;
0bb3d40f
JG
301 incnotewitnesses)
302 zcash_rpc zcbenchmark incnotewitnesses 1 "${@:3}"
303 ;;
c66c731a
JG
304 connectblockslow)
305 extract_benchmark_data
306 zcash_rpc zcbenchmark connectblockslow 1
307 ;;
d578de8e
TH
308 *)
309 zcashd_valgrind_stop
72b4f0b3 310 echo "Bad arguments to valgrind."
d578de8e
TH
311 exit 1
312 esac
313 zcashd_valgrind_stop
314 rm -f valgrind.out
315 ;;
88325d8a
TH
316 valgrind-tests)
317 case "$2" in
318 gtest)
319 rm -f valgrind.out
320 valgrind --leak-check=yes -v --error-limit=no --log-file="valgrind.out" ./src/zcash-gtest
321 cat valgrind.out
322 rm -f valgrind.out
323 ;;
324 test_bitcoin)
325 rm -f valgrind.out
326 valgrind --leak-check=yes -v --error-limit=no --log-file="valgrind.out" ./src/test/test_bitcoin
327 cat valgrind.out
328 rm -f valgrind.out
329 ;;
330 *)
72b4f0b3 331 echo "Bad arguments to valgrind-tests."
88325d8a
TH
332 exit 1
333 esac
334 ;;
36b1269b 335 *)
72b4f0b3 336 echo "Invalid benchmark type."
36b1269b
TH
337 exit 1
338esac
a0be8e26 339
51c8c56b 340# Cleanup
51c8c56b 341rm -rf "$DATADIR"
This page took 0.10345 seconds and 4 git commands to generate.