Skip to content

Commit

Permalink
add warm cache benchmark script
Browse files Browse the repository at this point in the history
  • Loading branch information
ruyadorno committed Jan 27, 2025
1 parent 22fb01b commit 82801ea
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,87 @@ jobs:
with:
name: vue-benchmark-results
path: ./results/vue/
next-warm:
name: 'Benchmark Next Project (warm cache)'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '22'
- name: Install & Setup Tools
run: |
bash ./scripts/setup.sh
- name: Run Project Benchmarks
run: |
bash ./scripts/install-warm.sh next
- name: Upload Benchmark Results
uses: actions/upload-artifact@v4
with:
name: next-benchmark-results
path: ./results/next/
astro-warm:
name: 'Benchmark Astro Project (warm cache)'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '22'
- name: Install & Setup Tools
run: |
bash ./scripts/setup.sh
- name: Run Project Benchmarks
run: |
bash ./scripts/install-warm.sh astro
- name: Upload Benchmark Results
uses: actions/upload-artifact@v4
with:
name: astro-benchmark-results
path: ./results/astro/
svelte-warm:
name: 'Benchmark Svelte Project (warm cache)'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '22'
- name: Install & Setup Tools
run: |
bash ./scripts/setup.sh
- name: Run Project Benchmarks
run: |
bash ./scripts/install-warm.sh svelte
- name: Upload Benchmark Results
uses: actions/upload-artifact@v4
with:
name: svelete-benchmark-results
path: ./results/svelte/
vue-warm:
name: 'Benchmark Vue Project (warm cache)'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v2
with:
node-version: '22'
- name: Install & Setup Tools
run: |
bash ./scripts/setup.sh
- name: Run Project Benchmarks (Vue)
run: |
bash ./scripts/install-warm.sh vue
- name: Upload Benchmark Results
uses: actions/upload-artifact@v4
with:
name: vue-benchmark-results
path: ./results/vue/


# make a chart with the results
chart:
Expand Down
69 changes: 69 additions & 0 deletions scripts/install-warm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

# WARNING
echo "WARNING: This script removes all installed packages, cache files & uncommitted git history. Changes have been stashed if this was unintended."

# Navigate to the fixture directory
cd ./fixtures/$1

# Create the results directory
mkdir -p ../../results/$1

# Run the benchmark suite
hyperfine --export-json=../../results/$1/benchmarks-warm-cache.json --warmup 3 --runs 10 -i --prepare 'rm -rf node_modules' --setup 'bash ../../scripts/clean.sh' \
-n 'npm' 'bash ../../scripts/install/npm.sh' \
-n 'yarn' 'bash ../../scripts/install/yarn.sh' \
-n 'berry' 'bash ../../scripts/install/berry.sh' \
-n 'pnpm' 'bash ../../scripts/install/pnpm.sh' \
-n 'vlt' 'bash ../../scripts/install/vlt.sh' \
-n 'bun' 'bash ../../scripts/install/bun.sh' \
-n 'deno' 'bash ../../scripts/install/deno.sh'

# Count the number of packages installed

# npm
bash ../../scripts/clean.sh
bash ../../scripts/install/npm.sh
NPM_COUNT=$(bash ../../scripts/package-count.sh)

# yarn
bash ../../scripts/clean.sh
bash ../../scripts/install/yarn.sh
YARN_COUNT=$(bash ../../scripts/package-count.sh)

# yarn berry
bash ../../scripts/clean.sh
bash ../../scripts/install/berry.sh
BERRY_COUNT=$(bash ../../scripts/package-count.sh)

# pnpm
bash ../../scripts/clean.sh
bash ../../scripts/install/pnpm.sh
PNPM_COUNT=$(bash ../../scripts/package-count.sh)

# vlt
bash ../../scripts/clean.sh
bash ../../scripts/install/vlt.sh
VLT_COUNT=$(bash ../../scripts/package-count.sh)

# bun
bash ../../scripts/clean.sh
bash ../../scripts/install/bun.sh
BUN_COUNT=$(bash ../../scripts/package-count.sh)

# deno
bash ../../scripts/clean.sh
bash ../../scripts/install/deno.sh
DENO_COUNT=$(bash ../../scripts/package-count.sh)

# Write the results to a file
echo "{
\"npm\": $NPM_COUNT,
\"yarn\": $YARN_COUNT,
\"berry\": $BERRY_COUNT,
\"pnpm\": $PNPM_COUNT,
\"vlt\": $VLT_COUNT,
\"bun\": $BUN_COUNT,
\"deno\": $DENO_COUNT
}" > ../../results/$1/package-count.json

0 comments on commit 82801ea

Please sign in to comment.