Skip to content

Commit

Permalink
feat: bench
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Dec 18, 2024
1 parent 61dcc7b commit 9a986a2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 31 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -351,36 +351,6 @@ jobs:
# reason for excluding https://github.com/napi-rs/napi-rs/issues/2200
run: cargo miri test --workspace --exclude rspack_binding_options --exclude rspack_node -- --nocapture

run_rust_benchmark:
name: Run rust benchmark
runs-on: ubuntu-latest
needs: [rust_changes, rust_check, rust_test]
steps:
- uses: actions/checkout@v4
- name: Pnpm Cache # Required by some tests
uses: ./.github/actions/pnpm-cache

- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }}
shared-key: check

- name: Install Tools
uses: taiki-e/install-action@v2
with:
tool: cargo-codspeed

- name: Build Benchmark
run: cargo codspeed build -p rspack_benchmark --features codspeed

- name: Run benchmark
uses: CodSpeedHQ/action@v3
timeout-minutes: 30
with:
run: pnpm run bench:ci
token: ${{ secrets.CODSPEED_TOKEN }}

run_benchmark:
name: Run benchmark
runs-on: ubuntu-latest
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,54 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ github.sha }}

bench:
needs: build
runs-on: ${{ fromJSON(needs.build.outputs.runner-labels) }}
steps:
- name: Checkout
if: ${{ !inputs.skipable }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
clean: ${{ startsWith(runner.name, 'GitHub Actions') }}

- name: Clean
if: ${{ !inputs.skipable && !startsWith(runner.name, 'GitHub Actions') }}
uses: ./.github/actions/clean
with:
target: ${{ inputs.target }}

- name: Download bindings
if: ${{ !inputs.skipable }}
uses: ./.github/actions/download-artifact
with:
name: bindings-${{ inputs.target }}
path: crates/node_binding/
try-local-cache: ${{ inputs.profile == 'debug' }}
link-when-local: true

- name: Show restored binding
if: ${{ !inputs.skipable }}
shell: bash
run: ls -lah crates/node_binding/*.node

- name: Setup Pnpm
if: ${{ !inputs.skipable }}
uses: ./.github/actions/pnpm-cache
with:
node-version: ${{ matrix.node }}

- name: Install Rust Toolchain
if: ${{ !inputs.skipable }}
uses: ./.github/actions/rustup
with:
save-cache: ${{ github.ref_name == 'main' }} # This should be safe because we have nightly building the cache every day
shared-key: build-${{ inputs.target }}

- name: Run benchmark
uses: CodSpeedHQ/action@v3
timeout-minutes: 30
with:
run: pnpm run bench:ci
token: ${{ secrets.CODSPEED_TOKEN }}
2 changes: 1 addition & 1 deletion packages/bench/ts-react.bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bench, describe } from "vitest";
import { rspack } from "@rspack/core";
import { bench, describe } from "vitest";
import rspackConfig from "./fixtures/ts-react/rspack.config";

describe("TypeScript React project", () => {
Expand Down

0 comments on commit 9a986a2

Please sign in to comment.