pionxzh / wakaru

🔪📦 Javascript decompiler for modern frontend
https://wakaru.vercel.app/
MIT License
251 stars 13 forks source link

Consider replacing prettier with biome for faster formatting #95

Open 0xdevalias opened 8 months ago

0xdevalias commented 8 months ago
0xdevalias commented 8 months ago

Benchmarking with hyperfine:

Running in the checked out directory of this repo (Ref):

⇒ npx prettier --version
3.1.1

⇒ npx biome --version
Version: 1.4.1

⇒ hyperfine --prepare 'git checkout -- unpacked/' 'npx prettier --write unpacked/' 'npx biome format --write unpacked/'
Benchmark 1: npx prettier --write unpacked/
  Time (mean ± σ):     13.243 s ±  0.675 s    [User: 21.156 s, System: 1.210 s]
  Range (min … max):   12.380 s … 14.071 s    10 runs

Benchmark 2: npx biome format --write unpacked/
  Time (mean ± σ):      1.514 s ±  0.135 s    [User: 3.343 s, System: 0.364 s]
  Range (min … max):    1.384 s …  1.775 s    10 runs

Summary
  npx biome format --write unpacked/ ran
    8.75 ± 0.90 times faster than npx prettier --write unpacked/

Config I used:

How that changed the formatted output:

Based on the speed+formatting improvements, I ended up switching my repo over to using it:

pionxzh commented 8 months ago

Thanks. I'm benchmarking and improving the performance recently. This can be a good replacement for prettier. I will test it soon.

Before switching to biome, I will have to refactor the transformation to allow async function.

Update: biome's format function is not async. There is no dependency.👍

pionxzh commented 7 months ago

I just tested oxc, but it's obviously not production ready yet. Will test biome later.

pionxzh commented 7 months ago

I'm also considering using dprint. Highly configurable. It also support adding braces, so that we can retire un-curly-braces.

0xdevalias commented 7 months ago

Hadn't come across that one before; sounds interesting:

Would be interested to see how it performs speed-wise for comparable formatting.