Open 0xdevalias opened 8 months ago
Benchmarking with hyperfine
:
A command-line benchmarking tool
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:
2.x
version of prettier
, so some of the changes shown here may have been improved/lessened if I formatted with a newer version of prettier
first)Based on the speed+formatting improvements, I ended up switching my repo over to using it:
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.👍
I just tested oxc
, but it's obviously not production ready yet. Will test biome later.
I'm also considering using dprint
. Highly configurable. It also support adding braces, so that we can retire un-curly-braces
.
Hadn't come across that one before; sounds interesting:
Pluggable and configurable code formatting platform written in Rust.
This is a process plugin. Using this will cause the CLI to download, run, and communicate with a separate process that is not sandboxed (unlike Wasm plugins).
Would be interested to see how it performs speed-wise for comparable formatting.