Skip to content

Commit

Permalink
chore: add benchmarking for example
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Jan 28, 2025
1 parent 732d1fb commit 6626cba
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
49 changes: 49 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Benchmarks

on:
push:
branches:
- main
pull_request:

jobs:
test:
name: Benchmark library
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Nargo
uses: noir-lang/[email protected]
with:
toolchain: 1.0.0-beta.0

- name: Install bb
run: |
npm install -g bbup
bbup -nv 1.0.0-beta.0
- name: Build Noir example
working-directory: ./example
run: nargo compile

- name: Generate gates report
run: ./scripts/build-gates-report.sh ./example/target
env:
BACKEND: /home/runner/.bb/bb

- name: Compare gates reports
id: gates_diff
uses: noir-lang/noir-gates-diff@7e4ddaa91c69380f15ccba514eac17bc7432a8cc
with:
report: gates_report.json
summaryQuantile: 0.9 # only display the 10% most significant circuit size diffs in the summary (defaults to 20%)

- name: Add gates diff to sticky comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: marocchino/sticky-pull-request-comment@v2
with:
# delete the comment in case changes no longer impact circuit sizes
delete: ${{ !steps.gates_diff.outputs.markdown }}
message: ${{ steps.gates_diff.outputs.markdown }}
2 changes: 1 addition & 1 deletion example/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dep::bignum::{params::BigNumParams, RuntimeBigNum};
use dep::bignum::{params::BigNumParams, runtime_bignum::RuntimeBigNumTrait};
use dep::rsa::{rsa::verify_sha256_pkcs1v15, types::RBN2048};

// Examples of the signature limbs, modulus, and redc params can be generated via
Expand Down
35 changes: 35 additions & 0 deletions scripts/build-gates-report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e

BACKEND=${BACKEND:-bb}

cd $(dirname "$0")/../

artifacts_path=${$1:-"./export"}
artifacts=$(ls $artifacts_path)

echo "{\"programs\": [" > gates_report.json

# Bound for checking where to place last parentheses
NUM_ARTIFACTS=$(ls -1q "$artifacts_path" | wc -l)

ITER="1"
for artifact in $artifacts; do
ARTIFACT_NAME=$(basename "$artifact")

GATES_INFO=$($BACKEND gates -b "$artifacts_path/$artifact")
MAIN_FUNCTION_INFO=$(echo $GATES_INFO | jq -r ".functions[0] | {package_name: "\"$ARTIFACT_NAME\"", functions: [{name: \"main\", acir_opcodes, opcodes: .acir_opcodes, circuit_size}], unconstrained_functions: []}")
echo -n $MAIN_FUNCTION_INFO >> gates_report.json

if (($ITER == $NUM_ARTIFACTS)); then
echo "" >> gates_report.json
else
echo "," >> gates_report.json
fi

ITER=$(( $ITER + 1 ))
done

echo "]}" >> gates_report.json


0 comments on commit 6626cba

Please sign in to comment.