feat(benches): add benchmarks for historic and latest events scanning #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run PR Benchmarks | |
| # This workflow runs benchmarks on pull requests and caches the results. | |
| # For security, benchmark results are uploaded as artifacts and tracked | |
| # by a separate workflow (pr_benchmarks_track.yml) that has access to secrets. | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| paths: | |
| # Only run benchmarks if relevant code changes | |
| - "src/**" | |
| - "benches/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| benchmark_historic: | |
| name: Run Historic Benchmarks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 | |
| with: | |
| egress-policy: audit | |
| - name: Free up disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf "/usr/local/share/boost" | |
| sudo rm -rf /usr/local/lib/android | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 | |
| - name: Install Foundry (Anvil) | |
| uses: foundry-rs/foundry-toolchain@v1 | |
| with: | |
| version: stable | |
| - name: Run historic benchmarks | |
| run: | | |
| cargo bench --manifest-path benches/Cargo.toml --bench historic_scanning 2>&1 | tee historic_results.txt | |
| - name: Upload historic benchmark results | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: historic_results.txt | |
| path: ./historic_results.txt | |
| benchmark_latest: | |
| name: Run Latest Events Benchmarks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 | |
| with: | |
| egress-policy: audit | |
| - name: Free up disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf "/usr/local/share/boost" | |
| sudo rm -rf /usr/local/lib/android | |
| df -h | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 | |
| - name: Install Foundry (Anvil) | |
| uses: foundry-rs/foundry-toolchain@v1 | |
| with: | |
| version: stable | |
| - name: Run latest events benchmarks | |
| run: | | |
| cargo bench --manifest-path benches/Cargo.toml --bench latest_events_scanning 2>&1 | tee latest_results.txt | |
| - name: Upload latest benchmark results | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: latest_results.txt | |
| path: ./latest_results.txt | |
| # Combine results after both benchmarks complete | |
| combine_results: | |
| name: Combine Benchmark Results | |
| runs-on: ubuntu-latest | |
| needs: [benchmark_historic, benchmark_latest] | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 | |
| with: | |
| egress-policy: audit | |
| - name: Download historic results | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| name: historic_results.txt | |
| - name: Download latest results | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| name: latest_results.txt | |
| - name: Combine benchmark results | |
| run: | | |
| echo "=== Historic Scanning Benchmarks ===" > benchmark_results.txt | |
| cat historic_results.txt >> benchmark_results.txt | |
| echo "" >> benchmark_results.txt | |
| echo "=== Latest Events Benchmarks ===" >> benchmark_results.txt | |
| cat latest_results.txt >> benchmark_results.txt | |
| - name: Upload combined benchmark results | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: benchmark_results.txt | |
| path: ./benchmark_results.txt | |
| - name: Upload PR event | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: event.json | |
| path: ${{ github.event_path }} |