-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run benchmarks using tinybench and CodSpeed (#404)
- Loading branch information
1 parent
aaf0a1f
commit 92ce554
Showing
8 changed files
with
462 additions
and
161 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,20 @@ jobs: | |
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
benchmark: | ||
name: Benchmark | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
cache: "npm" | ||
- name: Install dependencies | ||
run: npm install --ignore-scripts --no-audit --no-fund | ||
- name: Run benchmarks | ||
uses: CodSpeedHQ/action@v2 | ||
with: | ||
token: ${{ secrets.CODSPEED_TOKEN }} | ||
run: npm run benchmark |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Bench } from "tinybench" | ||
import { withCodSpeed } from "@codspeed/tinybench-plugin" | ||
import * as fs from "fs" | ||
import { analyze } from '../src/index.js' | ||
|
||
let filelist = fs.readdirSync('./src/__fixtures__') | ||
let files = filelist | ||
.filter(filename => filename.endsWith('.css')) | ||
.filter(filename => filename.includes('css-tricks')) | ||
.reduce((acc, filename) => { | ||
let css = fs.readFileSync(`./src/__fixtures__/${filename}`, 'utf8') | ||
acc.set(filename, css) | ||
return acc | ||
}, new Map()) | ||
|
||
let bench = withCodSpeed(new Bench()) | ||
|
||
for (let [filename, css] of files) { | ||
let byte_size = (Buffer.byteLength(css) / 1024).toFixed(1) | ||
bench.add(`${filename} (${byte_size}kB)`, () => analyze(css)) | ||
} | ||
|
||
await bench.warmup() | ||
await bench.run() | ||
|
||
console.table(bench.table()) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.