镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Commit dc7bf53

Browse files
committed
chore: perf improvements
1 parent 02d2f04 commit dc7bf53

5 files changed

Lines changed: 140 additions & 304 deletions

File tree

‎README.md‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,39 +297,39 @@ Pickier `formatCode()` and Prettier `format()` run in-process. oxfmt and Biome a
297297

298298
| File | Pickier | Biome (stdin) | oxfmt (stdin) | Prettier |
299299
|------|--------:|--------------:|--------------:|---------:|
300-
| Small (52 lines, 1 KB) | **73 us** | 42 ms | 52 ms | 1.8 ms |
301-
| Medium (419 lines, 10 KB) | **696 us** | 45 ms | 52 ms | 10.9 ms |
302-
| Large (1,279 lines, 31 KB) | **2.1 ms** | 48 ms | 52 ms | 28.2 ms |
300+
| Small (52 lines, 1 KB) | **56 us** | 41 ms | 51 ms | 1.6 ms |
301+
| Medium (419 lines, 10 KB) | **535 us** | 44 ms | 51 ms | 10.5 ms |
302+
| Large (1,279 lines, 31 KB) | **1.6 ms** | 47 ms | 51 ms | 28.0 ms |
303303

304304
### CLI (single file)
305305

306306
All four tools spawn a process and read the file from disk.
307307

308308
| File | Pickier | Biome | oxfmt | Prettier |
309309
|------|--------:|------:|------:|---------:|
310-
| Small (52 lines) | **64 ms** | 45 ms | 72 ms | 108 ms |
311-
| Medium (419 lines) | **63 ms** | 55 ms | 71 ms | 148 ms |
312-
| Large (1,279 lines) | **63 ms** | 92 ms | 72 ms | 181 ms |
310+
| Small (52 lines) | **49 ms** | 44 ms | 72 ms | 106 ms |
311+
| Medium (419 lines) | **50 ms** | 55 ms | 69 ms | 148 ms |
312+
| Large (1,279 lines) | **52 ms** | 91 ms | 71 ms | 177 ms |
313313

314314
### CLI Batch (all files, sequential)
315315

316316
| Tool | Time |
317317
|------|-----:|
318-
| Pickier | **190 ms** |
319-
| Biome | 192 ms |
320-
| oxfmt | 212 ms |
321-
| Prettier | 461 ms |
318+
| Pickier | **150 ms** |
319+
| Biome | 190 ms |
320+
| oxfmt | 209 ms |
321+
| Prettier | 431 ms |
322322

323323
### Throughput (large file x 20)
324324

325325
| Tool | Time |
326326
|------|-----:|
327-
| Pickier | **46 ms** |
328-
| Prettier | 567 ms |
329-
| Biome (stdin) | 984 ms |
330-
| oxfmt (stdin) | 1,110 ms |
327+
| Pickier | **33 ms** |
328+
| Prettier | 557 ms |
329+
| Biome (stdin) | 979 ms |
330+
| oxfmt (stdin) | 1,030 ms |
331331

332-
> Pickier's in-memory API is **13-25x faster than Prettier** and orders of magnitude faster than tools that must spawn a process. On CLI, Pickier's format-only fast path keeps time flat at ~63ms regardless of file size. Biome is faster on small CLI files thanks to its native Rust binary, but Pickier pulls ahead on large files and batch workloads where its integrated pipeline avoids per-file overhead. At throughput scale (20x large file), Pickier is **12x faster** than Prettier and **21-24x faster** than Biome/oxfmt.
332+
> Pickier's in-memory API is **17-29x faster than Prettier** and orders of magnitude faster than tools that must spawn a process. On CLI, Pickier's format-only fast path keeps time flat at ~50ms regardless of file size. Biome is slightly faster on small CLI files thanks to its native Rust binary, but Pickier pulls ahead on medium/large files and batch workloads. At throughput scale (20x large file), Pickier is **17x faster** than Prettier and **30x faster** than Biome/oxfmt.
333333
334334
```bash
335335
# reproduce locally

‎bechmarks/README.md‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,43 @@ Pickier `formatCode()` and Prettier `format()` run in-process. oxfmt and Biome a
1212

1313
| File | Pickier | Biome (stdin) | oxfmt (stdin) | Prettier |
1414
|------|--------:|--------------:|--------------:|---------:|
15-
| Small (52 lines, 1 KB) | **73 us** | 42 ms | 52 ms | 1.8 ms |
16-
| Medium (419 lines, 10 KB) | **696 us** | 45 ms | 52 ms | 10.9 ms |
17-
| Large (1,279 lines, 31 KB) | **2.1 ms** | 48 ms | 52 ms | 28.2 ms |
15+
| Small (52 lines, 1 KB) | **56 us** | 41 ms | 51 ms | 1.6 ms |
16+
| Medium (419 lines, 10 KB) | **535 us** | 44 ms | 51 ms | 10.5 ms |
17+
| Large (1,279 lines, 31 KB) | **1.6 ms** | 47 ms | 51 ms | 28.0 ms |
1818

19-
Pickier's in-memory API is 13-25x faster than Prettier and orders of magnitude faster than tools that must spawn a process per call.
19+
Pickier's in-memory API is 17-29x faster than Prettier and orders of magnitude faster than tools that must spawn a process per call.
2020

2121
### Formatting — CLI
2222

2323
All four tools spawn a process and read the file from disk.
2424

2525
| File | Pickier | Biome | oxfmt | Prettier |
2626
|------|--------:|------:|------:|---------:|
27-
| Small (52 lines) | **64 ms** | 45 ms | 72 ms | 108 ms |
28-
| Medium (419 lines) | **63 ms** | 55 ms | 71 ms | 148 ms |
29-
| Large (1,279 lines) | **63 ms** | 92 ms | 72 ms | 181 ms |
27+
| Small (52 lines) | **49 ms** | 44 ms | 72 ms | 106 ms |
28+
| Medium (419 lines) | **50 ms** | 55 ms | 69 ms | 148 ms |
29+
| Large (1,279 lines) | **52 ms** | 91 ms | 71 ms | 177 ms |
3030

31-
Pickier's format-only fast path keeps CLI time flat at ~63ms regardless of file size. Biome is faster on small files thanks to its native Rust binary, but slower on large files. Prettier is 1.7-2.9x slower across all sizes.
31+
Pickier's format-only fast path keeps CLI time flat at ~50ms regardless of file size. Biome is slightly faster on small files thanks to its native Rust binary, but slower on medium and large files. Prettier is 2-3.4x slower across all sizes.
3232

3333
### Formatting — CLI Batch (all fixtures sequential)
3434

3535
| Tool | Time |
3636
|------|-----:|
37-
| Pickier | **190 ms** |
38-
| Biome | 192 ms |
39-
| oxfmt | 212 ms |
40-
| Prettier | 461 ms |
37+
| Pickier | **150 ms** |
38+
| Biome | 190 ms |
39+
| oxfmt | 209 ms |
40+
| Prettier | 431 ms |
4141

4242
### Formatting — Throughput (large file x 20)
4343

4444
| Tool | Time |
4545
|------|-----:|
46-
| Pickier | **46 ms** |
47-
| Prettier | 567 ms |
48-
| Biome (stdin) | 984 ms |
49-
| oxfmt (stdin) | 1,110 ms |
46+
| Pickier | **33 ms** |
47+
| Prettier | 557 ms |
48+
| Biome (stdin) | 979 ms |
49+
| oxfmt (stdin) | 1,030 ms |
5050

51-
At scale, Pickier is 12x faster than Prettier and 21-24x faster than Biome/oxfmt.
51+
At scale, Pickier is 17x faster than Prettier and 30x faster than Biome/oxfmt.
5252

5353
### Linting — Pickier vs ESLint (programmatic)
5454

‎bechmarks/benchmarks/format-comparison.bench.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const biomeGlobal = which('biome')
6565
const biomeCmd = biomeGlobal ?? 'npx --yes @biomejs/biome'
6666
const prettierGlobal = which('prettier')
6767
const prettierCmd = prettierGlobal ?? 'npx --yes prettier'
68-
const pickierBin = resolve(__dirname, '../../packages/pickier/bin/cli.ts')
68+
const pickierBin = resolve(__dirname, '../../packages/pickier/dist/bin/cli.js')
6969

7070
// Warm up npx cache so the first bench iteration isn't penalised
7171
try { execSync(`${oxfmtCmd} --version`, { stdio: 'ignore' }) } catch { /* ignore */ }

0 commit comments

Comments
 (0)