Skip to content

Commit 1197e76

Browse files
committed
add table
1 parent e3de00a commit 1197e76

File tree

6 files changed

+97
-30
lines changed

6 files changed

+97
-30
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
node_modules

BENCHMARKS.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ Codspeed measures performance by cpu instructions.
1919

2020
<img src="./bar-graph.svg">
2121

22-
| | `oxc` | `swc` | `biome` |
23-
|:--------------------|:-------------------------|:---------------------------------|:--------------------------------- |
24-
| **`single-thread`** | `58.31 ms` (✅ **1.00x**) | `210.81 ms` (❌ *3.62x slower*) | `324.68 ms` (❌ *5.57x slower*) |
25-
| **`no-drop`** | `58.43 ms` (✅ **1.00x**) | `193.08 ms` (❌ *3.30x slower*) | `283.26 ms` (❌ *4.85x slower*) |
26-
| **`parallel`** | `72.39 ms` (✅ **1.00x**) | `257.81 ms` (❌ *3.56x slower*) | `434.60 ms` (❌ *6.00x slower*) |
22+
### cal.com.tsx
23+
24+
| | oxc | swc |biome |
25+
| ------------- | ---------------- | ----------------- |----------------- |
26+
| no-drop | `3.9 ms` (1.00x) | `15.9 ms` (4.03x) |`20.8 ms` (5.29x) |
27+
| parallel | `7.4 ms` (1.00x) | `32.4 ms` (4.40x) |`40.6 ms` (5.50x) |
28+
| single-thread | `3.9 ms` (1.00x) | `16.5 ms` (4.21x) |`20.8 ms` (5.30x) |
29+
30+
### typescript.js
31+
32+
| | oxc | swc |biome |
33+
| ------------- | ----------------- | ------------------ |------------------ |
34+
| no-drop | `29.4 ms` (1.00x) | `111.5 ms` (3.79x) |`159.0 ms` (5.41x) |
35+
| parallel | `49.5 ms` (1.00x) | `236.7 ms` (4.78x) |`337.9 ms` (6.83x) |
36+
| single-thread | `29.4 ms` (1.00x) | `113.2 ms` (3.85x) |`167.9 ms` (5.71x) |
2737

2838
#### single-thread
2939

@@ -77,13 +87,10 @@ cargo bench
7787
Generate the table
7888

7989
```bash
80-
cargo install cargo-criterion
81-
cargo install criterion-table
82-
cargo criterion --message-format=json | criterion-table > BENCHMARKS.md
90+
pnpm i
91+
pnpm run table
8392
```
8493

85-
Generate the bar graph: https://www.rapidtables.com/tools/bar-graph.html
86-
8794
## Input
8895

8996
* File: https://cdn.jsdelivr.net/npm/[email protected]/lib/typescript.js

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "bench-javascript-parser-written-in-rust",
3+
"version": "1.0.0",
4+
"private": true,
5+
"scripts": {
6+
"table": "node table.mjs"
7+
},
8+
"devDependencies": {
9+
"markdown-table": "^3.0.3"
10+
}
11+
}

pnpm-lock.yaml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

table.mjs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import fs from 'node:fs'
2+
import { markdownTable } from 'markdown-table'
3+
4+
async function readData() {
5+
const data = {};
6+
const dir = "./target/criterion";
7+
8+
const groups = await fs.promises.readdir(dir);
9+
for (const group of groups) {
10+
data[group] ||= {};
11+
12+
const benches = await fs.promises.readdir(`${dir}/${group}`);
13+
for (const bench of benches) {
14+
data[group][bench] ||= {};
15+
16+
const measurements = await fs.promises.readdir(`${dir}/${group}/${bench}`);
17+
for (const measurement of measurements) {
18+
const json = await import(`${dir}/${group}/${bench}/${measurement}/new/estimates.json`, { assert: { type: "json" } });
19+
const duration_ms = json.default.mean.point_estimate / 1_000_000;
20+
data[group][bench][measurement] ||= { duration_ms };
21+
}
22+
}
23+
}
24+
25+
return data
26+
}
27+
28+
async function main() {
29+
const data = await readData();
30+
const groups = Object.keys(data);
31+
const columns = Object.keys(data[groups[0]]);
32+
const rows = Object.keys(data[groups[0]][columns[0]]);
33+
34+
35+
for (const group of groups) {
36+
console.log(`### ${group}`);
37+
console.log()
38+
const table = [["", ...columns]];
39+
for (const row of rows) {
40+
const column_numbers = columns.map((column) => data[group][column][row].duration_ms);
41+
const minimum = Math.min(...column_numbers);
42+
const column_values = column_numbers.map((number) => {
43+
return `\`${number.toFixed(1)} ms\` (${(number / minimum).toFixed(2)}x)`
44+
});
45+
table.push([row, ...column_values]);
46+
}
47+
console.log(markdownTable(table));
48+
console.log()
49+
}
50+
}
51+
52+
main()

0 commit comments

Comments
 (0)