rwasm 0.4.3

ZK-friendly WebAssembly runtime optimized for blockchain and zero-knowledge applications
Documentation
name: Bench

on:
  push:
    branches: [ main, devel ]
  pull_request:
    branches: [ main, devel ]
  workflow_dispatch:

jobs:
  baseline-on-push:
    if: github.event_name == 'push'
    runs-on: [self-hosted, linux]
    steps:
      - uses: actions/checkout@v6

      - name: Install clang and build tools
        run: |
          sudo apt-get update
          sudo apt-get install -y clang libclang-dev pkg-config

      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Run Criterion (save baseline "devel")
        env:
          CRITERION_NO_PLOTTING: "1"
          CRITERION_WARM_UP_TIME: "3"
          CRITERION_MEASUREMENT_TIME: "5"
          CRITERION_SAMPLE_SIZE: "50"
        run: |
          rustup target add wasm32-unknown-unknown
          rustup +nightly-2025-09-20 target add wasm32-unknown-unknown
          make && cargo bench -- --save-baseline devel

      - name: Upload baseline artifact
        uses: actions/upload-artifact@v7
        with:
          name: criterion-baseline-devel
          path: benchmarks/target/criterion
          if-no-files-found: error
          compression-level: 6

  compare-on-pr:
    if: github.event_name == 'pull_request'
    runs-on: [self-hosted, linux]
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v6

      - name: Install clang and build tools
        run: |
          sudo apt-get update
          sudo apt-get install -y clang libclang-dev pkg-config

      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Download baseline from devel
        id: dl
        uses: dawidd6/action-download-artifact@v19
        continue-on-error: true
        with:
          workflow: bench.yml
          workflow_conclusion: success
          name: criterion-baseline-devel
          branch: devel
          path: benchmarks/target/criterion

      - name: Run Criterion (compare if baseline exists)
        env:
          CRITERION_NO_PLOTTING: "1"
          CRITERION_WARM_UP_TIME: "1"
          CRITERION_MEASUREMENT_TIME: "2"
          CRITERION_SAMPLE_SIZE: "20"
        run: |
          BASEFLAG=""
          if [ -d "benchmarks/target/criterion" ]; then
            BASEFLAG="--baseline devel"
          fi
          rustup target add wasm32-unknown-unknown
          rustup +nightly-2025-09-20 target add wasm32-unknown-unknown
          make && cargo bench -- $BASEFLAG | tee bench_output.txt

      - name: Upload full report
        uses: actions/upload-artifact@v7
        with:
          name: criterion-report-${{ github.sha }}
          path: benchmarks/target/criterion
          compression-level: 6

      - name: Post summary in PR
        run: |
          {
            echo "### Criterion results (vs baseline)"
            echo
            echo '```'
            sed -n '1,200p' bench_output.txt
            echo '```'
            echo
            echo "_Heads-up_: runner perf is noisy; treat deltas as a smoke check."
          } > comment.md

      - uses: marocchino/sticky-pull-request-comment@v3
        if: ${{ !github.event.pull_request.head.repo.fork }}
        with:
          path: comment.md