mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
Closes #2616. Adds benchmarks for NodeJS NAPI build. Measurement includes `JSON.parse` of the AST on JS side, since that's how it'll be used 99% of the time. Benchmarks run against same files as Rust parser benchmarks, so we can see the overhead of transferring AST to JS.
83 lines
2.5 KiB
YAML
83 lines
2.5 KiB
YAML
name: Benchmark
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
types: [opened, synchronize]
|
|
paths:
|
|
- '**/*.rs'
|
|
- 'Cargo.lock'
|
|
- '.github/workflows/benchmark.yml'
|
|
push:
|
|
branches:
|
|
- main
|
|
- bench-*
|
|
paths:
|
|
- '**/*.rs'
|
|
- 'Cargo.lock'
|
|
- '.github/workflows/benchmark.yml'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
benchmark:
|
|
name: Benchmark
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
progress: false
|
|
persist-credentials: false
|
|
|
|
- name: Install Rust Toolchain
|
|
uses: ./.github/actions/rustup
|
|
with:
|
|
shared-key: 'benchmark'
|
|
save-cache: ${{ github.ref_name == 'main' }}
|
|
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Install codspeed
|
|
uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: cargo-codspeed
|
|
|
|
- name: Build Benchmark
|
|
env:
|
|
RUSTFLAGS: "-C debuginfo=2 -C strip=none -g --cfg codspeed"
|
|
shell: bash
|
|
run: |
|
|
cargo build --release -p oxc_benchmark --features codspeed --bench lexer --bench parser --bench transformer --bench semantic --bench linter --bench minifier --bench codegen_sourcemap
|
|
mkdir -p target/codspeed/oxc_benchmark/
|
|
mv target/release/deps/lexer-* target/codspeed/oxc_benchmark
|
|
mv target/release/deps/parser-* target/codspeed/oxc_benchmark
|
|
mv target/release/deps/transformer-* target/codspeed/oxc_benchmark
|
|
mv target/release/deps/semantic-* target/codspeed/oxc_benchmark
|
|
mv target/release/deps/linter-* target/codspeed/oxc_benchmark
|
|
mv target/release/deps/minifier-* target/codspeed/oxc_benchmark
|
|
mv target/release/deps/codegen_sourcemap-* target/codspeed/oxc_benchmark
|
|
rm -rf target/codspeed/oxc_benchmark/*.d
|
|
|
|
- name: Build NAPI benchmark
|
|
working-directory: ./napi/parser
|
|
run: |
|
|
corepack enable
|
|
pnpm install
|
|
pnpm run build
|
|
|
|
- name: Run benchmark
|
|
uses: CodSpeedHQ/action@v2
|
|
timeout-minutes: 30
|
|
with:
|
|
run: |
|
|
cargo codspeed run
|
|
cd napi/parser
|
|
pnpm run bench
|
|
token: ${{ secrets.CODSPEED_TOKEN }}
|