Skip to content

Commit a52a1cf

Browse files
Updated benchmarking scripts
1 parent 3c506d4 commit a52a1cf

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

lib/ext/prophecyExt/prophecyExt.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module ProphecyExt (Cont : ListApi) = struct
6666
(* This is to provide access to the ListExt API to other modules depending on this module, since other extensions rely on the ListExt. *)
6767
module ListFns = Cont.ListFns
6868

69-
(** AstDef *)
69+
(* AstDef *)
7070

7171
(* Standard pattern: match on our constructors, defer the rest. *)
7272
let type_ext_to_name type_ext = match type_ext with

scripts/bench_ext.sh

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ EXT_LIST=(
1818
"lib/ext/listExt"
1919
)
2020

21-
EXAMPLES=(
21+
EC_EXAMPLES=(
2222
"test/ext_error-credits/amortised_hash.rav"
2323
"test/ext_error-credits/cf_hashmap.rav"
2424
"test/ext_error-credits/ec_dynamic_vec.rav"
25-
#
25+
)
26+
27+
PROPH_EXAMPLES=(
2628
"test/ext_prophecy/clairvoyant_coin.rav"
2729
"test/ext_prophecy/lazy_coin.rav"
2830
"test/ext_prophecy/rdcss.rav"
@@ -89,22 +91,19 @@ count_line() {
8991

9092

9193
run_benchmark() {
92-
# local array_name=$1
94+
local array_name="$1[@]"
9395
local args=$2
94-
# local files=("${!array_name}")
95-
# Print table header
96-
printf "%-45s %10s %10s %10s %10s %10s\n" "File" "ProgLen" "ProofDecl" "ProofInstr" "Overhead" "Runtime(s)"
97-
printf "%-45s %10s %10s %10s %10s %10s\n" "$(printf '%.0s=' {1..45})" "$(printf '%.0s=' {1..10})" "$(printf '%.0s=' {1..10})" "$(printf '%.0s=' {1..10})" "$(printf '%.0s=' {1..10})" "$(printf '%.0s=' {1..10})"
96+
local files=("${!array_name}")
9897

99-
for file in "${EXAMPLES[@]}"; do
98+
for file in "${files[@]}"; do
10099
if [ -z "$file" ]; then
101100
echo ""
102101
continue
103102
fi
104103

105104
# echo "Running file $file"
106105
line_count=$(wc -l < "$file")
107-
output=$(raven "$file" --stats)
106+
output=$(eval "raven $args '$file' --stats")
108107

109108
# Extract statistics from the output
110109
program_declarations=$(echo "$output" | grep "Program Declarations" | awk '{print $3}')
@@ -135,7 +134,7 @@ run_benchmark() {
135134
fi
136135

137136
# Run hyperfine to measure runtime
138-
runtime=$(hyperfine --warmup $WARMUP --runs $RUNS $args "raven \"$file\"" --export-json /tmp/hyperfine.json)
137+
runtime=$(hyperfine --warmup $WARMUP --runs $RUNS --export-json /tmp/hyperfine.json -- "raven $args \"$file\"")
139138
runtime=$(jq '.results[0].mean' /tmp/hyperfine.json)
140139
runtime=$(printf "%.3f" "$runtime")
141140

@@ -150,4 +149,9 @@ count_line
150149
echo
151150

152151
echo "Table 2: Program Overhead and Runtimes for Benchmark Examples"
153-
run_benchmark
152+
# Print table header
153+
printf "%-45s %10s %10s %10s %10s %10s\n" "File" "ProgLen" "ProofDecl" "ProofInstr" "Overhead" "Runtime(s)"
154+
printf "%-45s %10s %10s %10s %10s %10s\n" "$(printf '%.0s=' {1..45})" "$(printf '%.0s=' {1..10})" "$(printf '%.0s=' {1..10})" "$(printf '%.0s=' {1..10})" "$(printf '%.0s=' {1..10})" "$(printf '%.0s=' {1..10})"
155+
run_benchmark EC_EXAMPLES "--extension eris"
156+
run_benchmark PROPH_EXAMPLES "--extension prophecy"
157+

scripts/count_sections.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ fi
3535
total_lines=0
3636

3737
# Process each section in order
38-
for section_name in "${SECTIONS[@]}"; do
38+
for i in "${!SECTIONS[@]}"; do
39+
section_name="${SECTIONS[$i]}"
40+
3941
# Find line number of section marker
4042
section_line=$(grep -n "(\* $section_name \*)" "$filepath" | cut -d: -f1 | head -1)
4143

@@ -44,11 +46,15 @@ for section_name in "${SECTIONS[@]}"; do
4446
continue
4547
fi
4648

47-
# Find the next section marker or use end of file
48-
next_section_line=$(tail -n +$((section_line + 1)) "$filepath" | grep -n "(\* [A-Za-z]* \*)" | head -1 | cut -d: -f1)
49-
50-
if [ -n "$next_section_line" ]; then
51-
end_line=$((section_line + next_section_line - 2))
49+
# Find the next section marker using the next section name
50+
if [ $((i + 1)) -lt ${#SECTIONS[@]} ]; then
51+
next_section_name="${SECTIONS[$((i + 1))]}"
52+
next_section_line=$(grep -n "(\* $next_section_name \*)" "$filepath" | cut -d: -f1 | head -1)
53+
if [ -n "$next_section_line" ]; then
54+
end_line=$((next_section_line - 2))
55+
else
56+
end_line=$(wc -l < "$filepath")
57+
fi
5258
else
5359
end_line=$(wc -l < "$filepath")
5460
fi
@@ -67,7 +73,7 @@ for section_name in "${SECTIONS[@]}"; do
6773
fi
6874

6975
# Clean up temp file
70-
rm -f "$temp_file"
76+
# rm -f "$temp_file"
7177

7278
# Print the row (CSV or table format)
7379
if [ "$csv_mode" = "--csv" ]; then

0 commit comments

Comments
 (0)