diff --git a/.github/workflows/bench-criterion.yml b/.github/workflows/bench-criterion.yml new file mode 100644 index 0000000000..f9853452be --- /dev/null +++ b/.github/workflows/bench-criterion.yml @@ -0,0 +1,83 @@ +name: Bench + +on: + pull_request: + branches: [main] + merge_group: + types: [checks_requested] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + +jobs: + run-criterion-bench: + name: Run Criterion Bench + runs-on: ubuntu-24.04 + env: + MLIR_SYS_190_PREFIX: /usr/lib/llvm-19/ + TABLEGEN_190_PREFIX: /usr/lib/llvm-19/ + LLVM_SYS_191_PREFIX: /usr/lib/llvm-19/ + defaults: + run: + shell: bash + working-directory: ./cairo_native + steps: + - name: Checkout commit + uses: actions/checkout@v4 + with: + path: cairo_native + + # Install dependencies and free space + - name: Install linux deps + uses: ./cairo_native/.github/actions/install-linux-deps + + - uses: dtolnay/rust-toolchain@1.89.0 + - uses: Swatinem/rust-cache@v2 + + - name: install deps head + run: make deps + + - name: Run head bench + run: cargo bench -F testing --bench benches -- --save-baseline bench-head + + - name: Checkout commit + uses: actions/checkout@v4 + with: + path: cairo_native + ref: main + + - name: install deps base + run: make deps + + - name: Run base bench + run: cargo bench -F testing --bench benches -- --save-baseline bench-base + + - name: Install critcmp + run: cargo install critcmp + + - name: Compre HEAD vs BASE + run: critcmp bench-base bench-head | tee -a comment_body.md + + - name: Create or update bench comment + continue-on-error: true + uses: peter-evans/create-or-update-comment@v4 + with: + comment-id: ${{ github.event.pull_request.number }} + issue-number: ${{ github.event.pull_request.number }} + body-path: comment_body.md + edit-mode: replace + + - name: Find Bench Comment + continue-on-error: true + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: "github-actions[bot]" + body-includes: Criterion results Main vs HEAD + +