11/**
22 * Pickier vs oxfmt vs Biome vs Prettier — Formatting Benchmark
33 *
4- * All four tools compared in every group:
4+ * All tools compared in every group:
55 *
66 * 1. Programmatic / In-memory
77 * Pickier formatCode() — in-memory, no process spawn
1111 *
1212 * 2. CLI (single file)
1313 * All tools spawn a subprocess.
14+ * Pickier uses its Zig-compiled native binary for max speed.
1415 *
1516 * 3. CLI Batch (all fixtures sequentially)
1617 *
@@ -65,7 +66,7 @@ const biomeGlobal = which('biome')
6566const biomeCmd = biomeGlobal ?? 'npx --yes @biomejs/biome'
6667const prettierGlobal = which ( 'prettier' )
6768const prettierCmd = prettierGlobal ?? 'npx --yes prettier'
68- const pickierBin = resolve ( __dirname , '../../packages/pickier/ bin/pickier' )
69+ const pickierZigBin = resolve ( __dirname , '../../packages/zig/zig-out/ bin/pickier-zig ' )
6970
7071// Warm up npx cache so the first bench iteration isn't penalised
7172try { execSync ( `${ oxfmtCmd } --version` , { stdio : 'ignore' } ) } catch { /* ignore */ }
@@ -124,9 +125,8 @@ function cliPrettier(filePath: string): void {
124125
125126function cliPickier ( filePath : string ) : void {
126127 try {
127- execSync ( `${ pickierBin } run ${ filePath } --mode format --check` , {
128+ execSync ( `${ pickierZigBin } run ${ filePath } --mode format --check` , {
128129 stdio : 'ignore' ,
129- env : { ...process . env , PICKIER_NO_AUTO_CONFIG : '1' } ,
130130 } )
131131 }
132132 catch { /* non-zero exit expected */ }
@@ -136,15 +136,15 @@ function cliPickier(filePath: string): void {
136136// Header
137137// ---------------------------------------------------------------------------
138138console . log ( `\n${ '=' . repeat ( 80 ) } ` )
139- console . log ( ' PICKIER vs OXFMT vs BIOME vs PRETTIER — Formatting Benchmark' )
139+ console . log ( ' PICKIER (Zig) vs OXFMT vs BIOME vs PRETTIER — Formatting Benchmark' )
140140console . log ( '=' . repeat ( 80 ) )
141141console . log ( '\nFixtures:' )
142142console . log ( ` Small: ${ stats . small . lines } lines (${ ( stats . small . bytes / 1024 ) . toFixed ( 1 ) } KB)` )
143143console . log ( ` Medium: ${ stats . medium . lines } lines (${ ( stats . medium . bytes / 1024 ) . toFixed ( 1 ) } KB)` )
144144console . log ( ` Large: ${ stats . large . lines } lines (${ ( stats . large . bytes / 1024 ) . toFixed ( 1 ) } KB)` )
145145console . log ( )
146146console . log ( 'Tools:' )
147- console . log ( ` Pickier: formatCode() in-memory + compiled binary CLI` )
147+ console . log ( ` Pickier: formatCode() in-memory + Zig- compiled native binary CLI` )
148148console . log ( ` oxfmt: ${ oxfmtGlobal ?? '(via npx)' } — stdin pipe + CLI (no JS API)` )
149149console . log ( ` Biome: ${ biomeGlobal ?? '(via npx)' } — stdin pipe + CLI (no JS formatting API)` )
150150console . log ( ` Prettier: format() in-memory + ${ prettierGlobal ?? 'npx' } CLI` )
@@ -180,7 +180,7 @@ for (const [label, size] of [['Small', 'small'], ['Medium', 'medium'], ['Large',
180180
181181for ( const [ label , size ] of [ [ 'Small' , 'small' ] , [ 'Medium' , 'medium' ] , [ 'Large' , 'large' ] ] as const ) {
182182 group ( `CLI — ${ label } File (${ stats [ size ] . lines } lines)` , ( ) => {
183- bench ( 'Pickier' , ( ) => {
183+ bench ( 'Pickier (Zig) ' , ( ) => {
184184 cliPickier ( fixturePaths [ size ] )
185185 } )
186186
@@ -203,7 +203,7 @@ for (const [label, size] of [['Small', 'small'], ['Medium', 'medium'], ['Large',
203203// ===================================================================
204204
205205group ( 'CLI Batch — All Files' , ( ) => {
206- bench ( 'Pickier' , ( ) => {
206+ bench ( 'Pickier (Zig) ' , ( ) => {
207207 for ( const fp of Object . values ( fixturePaths ) ) cliPickier ( fp )
208208 } )
209209
0 commit comments