Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reduce number of benchmarking scripts #7285

Merged
merged 16 commits into from
Feb 6, 2025
22 changes: 11 additions & 11 deletions .github/actions/download-nargo/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ description: Downloads the nargo binary from an artifact and adds it to the path
runs:
using: composite
steps:
- name: Download nargo binary
uses: actions/download-artifact@v4
with:
name: nargo
path: ./nargo
- name: Download nargo binary
uses: actions/download-artifact@v4
with:
name: nargo
path: ./nargo

- name: Set nargo on PATH
shell: bash
run: |
nargo_binary="${{ github.workspace }}/nargo/nargo"
chmod +x $nargo_binary
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
- name: Set nargo on PATH
shell: bash
run: |
nargo_binary="${{ github.workspace }}/nargo/nargo"
chmod +x $nargo_binary
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
27 changes: 0 additions & 27 deletions .github/scripts/merge-bench-reports.sh

This file was deleted.

35 changes: 19 additions & 16 deletions .github/workflows/reports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ jobs:
sparse-checkout-cone-mode: false

- name: Download nargo binary
uses: scripts/.github/actions/download-nargo
uses: ./scripts/.github/actions/download-nargo

- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -390,7 +390,7 @@ jobs:
with:
path: scripts
sparse-checkout: |
./.github/actions/download-nargo/action.yml
.github/actions/download-nargo/action.yml
test_programs/memory_report.sh
test_programs/parse_memory.sh
sparse-checkout-cone-mode: false
Expand Down Expand Up @@ -477,18 +477,20 @@ jobs:
uses: actions/download-artifact@v4
with:
name: in_progress_compilation_report
path: ./reports

- name: Download matrix compilation reports
uses: actions/download-artifact@v4
with:
pattern: compilation_report_*
path: ./reports
merge-multiple: true

- name: Merge compilation reports using jq
run: |
mv ./.github/scripts/merge-bench-reports.sh merge-bench-reports.sh
./merge-bench-reports.sh compilation_report
jq ".compilation_reports | map({name: .artifact_name, value: (.time[:-1] | tonumber), unit: \"s\"}) " ./compilation_report.json > time_bench.json
# Github actions seems to not expand "**" in globs by default.
shopt -s globstar
jq --slurp '. | flatten' ./reports/* | tee time_bench.json

- name: Store benchmark result
continue-on-error: true
Expand Down Expand Up @@ -532,12 +534,13 @@ jobs:
with:
pattern: compilation_mem_report_*
path: ./reports
merge-multiple: true

- name: Merge memory reports using jq
run: |
mv ./.github/scripts/merge-bench-reports.sh merge-bench-reports.sh
./merge-bench-reports.sh memory_report
jq ".memory_reports | map({name: .artifact_name, value: (.peak_memory | tonumber), unit: \"MB\"}) " ./memory_report.json > memory_bench.json
# Github actions seems to not expand "**" in globs by default.
shopt -s globstar
jq --slurp '. | flatten' ./reports/* | tee memory_bench.json

- name: Store benchmark result
continue-on-error: true
Expand Down Expand Up @@ -581,14 +584,13 @@ jobs:
with:
pattern: execution_mem_report_*
path: ./reports
merge-multiple: true

- name: Merge memory reports using jq
run: |
mv ./.github/scripts/merge-bench-reports.sh merge-bench-reports.sh
./merge-bench-reports.sh memory_report
# Rename the memory report as to not clash with the compilation memory report file name
cp memory_report.json execution_memory_report.json
jq ".memory_reports | map({name: .artifact_name, value: (.peak_memory | tonumber), unit: \"MB\"}) " ./execution_memory_report.json > memory_bench.json
# Github actions seems to not expand "**" in globs by default.
shopt -s globstar
jq --slurp '. | flatten' ./reports/* | tee memory_bench.json

- name: Store benchmark result
continue-on-error: true
Expand Down Expand Up @@ -633,12 +635,13 @@ jobs:
with:
pattern: execution_report_*
path: ./reports
merge-multiple: true

- name: Merge execution reports using jq
run: |
mv ./.github/scripts/merge-bench-reports.sh merge-bench-reports.sh
./merge-bench-reports.sh execution_report
jq ".execution_reports | map({name: .artifact_name, value: (.time[:-1] | tonumber), unit: \"s\"}) " ./execution_report.json > time_bench.json
# Github actions seems to not expand "**" in globs by default.
shopt -s globstar
jq --slurp '. | flatten' ./reports/* | tee time_bench.json

- name: Store benchmark result
continue-on-error: true
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-js-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ jobs:
TEST_REPORT_NAME=test_report_$NAME
echo "test_report_name=$TEST_REPORT_NAME" >> $GITHUB_OUTPUT

jq --null-input "{ test_reports: [{ name: \"$NAME\", value: (\"$TIME\" | tonumber), unit: \"s\" }]}" > $TEST_REPORT_NAME.json
jq --null-input "[{ name: \"$NAME\", value: (\"$TIME\" | tonumber), unit: \"s\" }]" > $TEST_REPORT_NAME.json

if [ ! -s $output_file ]; then
# The file is empty so we delete it to signal that `nargo test` failed before it could run any tests
Expand Down Expand Up @@ -613,13 +613,13 @@ jobs:
with:
pattern: test_report_*
path: ./reports
merge-multiple: true

- name: Merge test reports using jq
run: |
jq --null-input "{ test_reports: [] }" > test_report.json
mv ./.github/scripts/merge-bench-reports.sh merge-bench-reports.sh
./merge-bench-reports.sh test_report
jq ".test_reports" < ./test_report.json > test_bench.json
# Github actions seems to not expand "**" in globs by default.
shopt -s globstar
jq --slurp '. | flatten' ./reports/* | tee test_bench.json

- name: Store benchmark result
continue-on-error: true
Expand Down
6 changes: 3 additions & 3 deletions test_programs/compilation_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ base_path="$current_dir/execution_success"
# Tests to be profiled for compilation report
tests_to_profile=("sha256_regression" "regression_4709" "ram_blowup_regression" "global_var_regression_entry_points")

echo "{\"compilation_reports\": [ " > $current_dir/compilation_report.json
echo "[ " > $current_dir/compilation_report.json

# If there is an argument that means we want to generate a report for only the current directory
if [ "$1" == "1" ]; then
Expand Down Expand Up @@ -62,7 +62,7 @@ for dir in ${tests_to_profile[@]}; do
printf "%.3f\n", 0
}' <<<"${TIMES[@]}")

jq -rc "{artifact_name: \"$PACKAGE_NAME\", time: \""$AVG_TIME"s\"}" --null-input >> $current_dir/compilation_report.json
jq -rc "{name: \"$PACKAGE_NAME\", value: \""$AVG_TIME"\" | tonumber, unit: \"s\"}" --null-input >> $current_dir/compilation_report.json

if (($ITER != $NUM_ARTIFACTS)); then
echo "," >> $current_dir/compilation_report.json
Expand All @@ -73,4 +73,4 @@ for dir in ${tests_to_profile[@]}; do
ITER=$(( $ITER + 1 ))
done

echo "]}" >> $current_dir/compilation_report.json
echo "]" >> $current_dir/compilation_report.json
6 changes: 3 additions & 3 deletions test_programs/execution_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ base_path="$current_dir/execution_success"
# Tests to be profiled for execution report
tests_to_profile=("sha256_regression" "regression_4709" "ram_blowup_regression" "global_var_regression_entry_points")

echo "{\"execution_reports\": [ " > $current_dir/execution_report.json
echo "[" > $current_dir/execution_report.json

# If there is an argument that means we want to generate a report for only the current directory
if [ "$1" == "1" ]; then
Expand Down Expand Up @@ -70,7 +70,7 @@ for dir in ${tests_to_profile[@]}; do
printf "%.3f\n", 0
}' <<<"${TIMES[@]}")

jq -rc "{artifact_name: \"$PACKAGE_NAME\", time: \""$AVG_TIME"s\"}" --null-input >> $current_dir/execution_report.json
jq -rc "{name: \"$PACKAGE_NAME\", value: \""$AVG_TIME"\" | tonumber, unit: \"s\"}" --null-input >> $current_dir/execution_report.json

if (($ITER != $NUM_ARTIFACTS)); then
echo "," >> $current_dir/execution_report.json
Expand All @@ -81,4 +81,4 @@ for dir in ${tests_to_profile[@]}; do
ITER=$(( $ITER + 1 ))
done

echo "]}" >> $current_dir/execution_report.json
echo "]" >> $current_dir/execution_report.json
7 changes: 4 additions & 3 deletions test_programs/memory_report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fi
FIRST="1"

FLAGS=${FLAGS:- ""}
echo "{\"memory_reports\": [ " > memory_report.json
echo "[" > memory_report.json

for test_name in ${tests_to_profile[@]}; do
cd $base_path/$test_name
Expand Down Expand Up @@ -57,8 +57,9 @@ for test_name in ${tests_to_profile[@]}; do
peak=${consumption:30:len}
rm $current_dir/$test_name"_heap_analysis.txt"
peak_memory=$($PARSE_MEMORY $peak)
echo -e " {\n \"artifact_name\":\"$test_name\",\n \"peak_memory\":\"$peak_memory\"\n }" >> $current_dir"/memory_report.json"
jq -rc "{name: \"$PACKAGE_NAME\", value: \"$peak_memory\" | tonumber, unit: \"MB\"}" --null-input >> $current_dir/memory_report.json

done

echo "]}" >> $current_dir"/memory_report.json"
echo "]" >> $current_dir"/memory_report.json"

Loading