-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbenchmark_fibo.sh
More file actions
executable file
·93 lines (82 loc) · 2.84 KB
/
Copy pathbenchmark_fibo.sh
File metadata and controls
executable file
·93 lines (82 loc) · 2.84 KB
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
#!/bin/bash
format_time() {
local seconds=$1
if (( $(echo "$seconds >= 60" | bc -l) )); then
local minutes=$(echo "$seconds / 60" | bc)
local remaining_seconds=$(echo "$seconds - ($minutes * 60)" | bc)
if (( $(echo "$remaining_seconds == ${remaining_seconds%.*}" | bc -l) )); then
printf "%dm%ds" $minutes ${remaining_seconds%.*}
else
printf "%dm%.1fs" $minutes $remaining_seconds
fi
else
if (( $(echo "$seconds == ${seconds%.*}" | bc -l) )); then
printf "%ds" ${seconds%.*}
else
printf "%.1fs" $seconds
fi
fi
}
if [ -n "$TEST_MODE" ]; then
echo "Running in test mode"
N_VALUES=(10)
else
N_VALUES=(10000 100000 1000000 4000000)
fi
OUTPUT_FILE="benchmark_fibo_results.csv"
# Detect CPU capabilities and set SP1/PICO configuration
if grep -q "avx512" /proc/cpuinfo; then
SP1_RUSTFLAGS="-C target-cpu=native -C target-feature=+avx512f"
SP1_NAME="SP1-AVX512"
PICO_RUSTFLAGS="-C target-cpu=native -C target-feature=+avx512f"
PICO_NAME="Pico-AVX512"
elif grep -q "avx2" /proc/cpuinfo; then
SP1_RUSTFLAGS="-C target-cpu=native"
SP1_NAME="SP1-AVX2"
PICO_RUSTFLAGS="-C target-cpu=native"
PICO_NAME="Pico-AVX2"
else
SP1_RUSTFLAGS=""
SP1_NAME="SP1-Base"
PICO_RUSTFLAGS=""
PICO_NAME="Pico-Base"
fi
# Build all projects
echo "Building all projects..."
make build_fibo_sp1 RUSTFLAGS="$SP1_RUSTFLAGS"
make build_fibo_pico
make build_fibo_risc0
# Initialize results file
echo "Prover,N,Time" > $OUTPUT_FILE
for n in "${N_VALUES[@]}"; do
# Pico benchmark
echo "Running Pico with N=$n"
start=$(date +%s.%N)
make fibo_pico_wrapped N=$n RUSTFLAGS="$PICO_RUSTFLAGS" > /dev/null 2>&1
end=$(date +%s.%N)
time=$(echo "$end - $start" | bc)
echo "$PICO_NAME Groth16,$n,$(format_time $time)" >> $OUTPUT_FILE
# SP1 Compressed benchmark
echo "Running SP1 (Compressed) with N=$n"
start=$(date +%s.%N)
make fibo_sp1 N=$n PROOF_MODE=compressed RUSTFLAGS="$SP1_RUSTFLAGS" > /dev/null 2>&1
end=$(date +%s.%N)
time=$(echo "$end - $start" | bc)
echo "$SP1_NAME,$n,$(format_time $time)" >> $OUTPUT_FILE
# SP1 Groth16 benchmark (Linux + Docker only)
if [[ "$(uname)" == "Linux" ]] && command -v docker >/dev/null 2>&1; then
echo "Running SP1 (Groth16) with N=$n"
start=$(date +%s.%N)
make fibo_sp1 N=$n PROOF_MODE=groth16 RUSTFLAGS="$SP1_RUSTFLAGS" > /dev/null 2>&1
end=$(date +%s.%N)
time=$(echo "$end - $start" | bc)
echo "$SP1_NAME-Groth16,$n,$(format_time $time)" >> $OUTPUT_FILE
fi
# RISC0 benchmark
echo "Running RISC0 with N=$n"
start=$(date +%s.%N)
make fibo_risc0 N=$n > /dev/null 2>&1
end=$(date +%s.%N)
time=$(echo "$end - $start" | bc)
echo "Risc0,$n,$(format_time $time)" >> $OUTPUT_FILE
done