-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench.sh
executable file
·70 lines (59 loc) · 1.45 KB
/
bench.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
#!/usr/bin/env bash
DEPTH="26"
URL="http://localhost:3001/prove"
gnark() {
local args=("$@")
./light-prover "${args[@]}"
}
generate_and_test() {
local utxos=$1
CIRCUIT_FILE="circuit_${DEPTH}_${utxos}.key"
TEST_FILE="inputs_${DEPTH}_${utxos}.json"
if [ ! -f "${CIRCUIT_FILE}" ]; then
echo "Prover setup..."
gnark setup --utxos "$utxos" --tree-depth "$DEPTH" --output "${CIRCUIT_FILE}"
fi
if [ ! -f "${TEST_FILE}" ]; then
echo "Generating test inputs..."
gnark gen-test-params --utxos "$utxos" --tree-depth "$DEPTH" > "${TEST_FILE}"
fi
}
run_benchmark() {
local utxos=$1
echo "Benchmarking with $utxos utxos..."
TEST_FILE="inputs_${DEPTH}_${utxos}.json"
curl -s -S -X POST -d @"${TEST_FILE}" "$URL" -o /dev/null
sleep 1
}
start_server() {
local -n arr=$1
for utxos in "${arr[@]}"
do
keys_file+="--keys-file circuit_${DEPTH}_${utxos}.key "
done
gnark start \
$keys_file \
--json-logging \
>> log.txt \
&
sleep 10
}
# Define an array containing the desired values
declare -a utxos_arr=("1" "2" "3" "4" "8")
# Kill the server
killall light-prover
# Generate keys and test inputs
for utxos in "${utxos_arr[@]}"
do
generate_and_test $utxos
done
# Start the server
start_server utxos_arr
# Run the benchmarks
for utxos in "${utxos_arr[@]}"
do
run_benchmark $utxos
done
echo "Done. Benchmarking results are in log.txt."
# Kill the server
killall light-prover