Skip to content

Commit

Permalink
Add a new workflow to compare performance
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Jan 6, 2025
1 parent c4f28d1 commit 5bc341b
Showing 1 changed file with 116 additions and 0 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/benchmark-compare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Benchmark

# only one can tun at a time.
# Actions access a common cache entry and may corrupt it.
concurrency: cd-benchmark-compare-${{ github.ref }}

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
nodejs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
# Get the entire git history to walk commit history on head branch
fetch-depth: 0
# Do not checkout merge commit
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/setup-node@v4
with:
node-version: "18"

- name: Install
run: yarn install --frozen-lockfile

- name: Run performance tests on node
run: yarn benchmark --local ./nodejs --noThrow ${{ github.event_name == 'push' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Archive nodejs benchmark artifacts
uses: actions/upload-artifact@v4
with:
name: nodejs-benchmark
path: nodejs

bun:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install Dependencies
run: bun install

- name: Run performance tests on bun
run: bun run --bun benchmark --local ./bun --noThrow ${{ github.event_name == 'push' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Archive bun benchmark artifacts
uses: actions/upload-artifact@v4
with:
name: bun-benchmark
path: bun

deno:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Install Dependencies
run: deno install

- name: Run performance tests on bun
run: deno run -A benchmark --local ./deno --noThrow ${{ github.event_name == 'push' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Archive deno benchmark artifacts
uses: actions/upload-artifact@v4
with:
name: deno-benchmark
path: deno

compare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/setup-node@v4
with:
node-version: "18"

- name: Install
run: yarn install --frozen-lockfile

- name: Download all benchmark artifacts
uses: actions/download-artifact@v4

- name: Run comparison
run: node --loader ts-node/esm ./src/cli/cli.ts cmp nodejs-benchmark deno-benchmark bun-benchmark

0 comments on commit 5bc341b

Please sign in to comment.