Skip to content

Commit 1247fbc

Browse files
committed
add memory measurement
1 parent 46f45aa commit 1247fbc

File tree

6 files changed

+56
-11
lines changed

6 files changed

+56
-11
lines changed

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ path = "src/swc.rs"
2020
name = "biome"
2121
path = "src/biome.rs"
2222

23-
[profile.release]
24-
opt-level = 3
25-
lto = "fat"
26-
codegen-units = 1
27-
strip = "symbols"
28-
debug = false
29-
panic = "abort"
30-
3123
[dependencies]
3224
oxc = "0.13.5"
3325

@@ -44,3 +36,11 @@ mimalloc = "0.1.42"
4436

4537
[features]
4638
codspeed = ["criterion2/codspeed"]
39+
40+
[profile.release]
41+
opt-level = 3
42+
lto = "fat"
43+
codegen-units = 1
44+
strip = "symbols"
45+
debug = false
46+
panic = "abort"

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ The purpose of this benchmark is for people who wants to evaluate and compare th
44

55
The numbers indicate that Oxc is at least 3 times faster than Swc and 5 times faster than Biome.
66

7-
## Results
7+
## CPU
88

9-
### Codspeed
9+
### Codspeed Measurement
1010

1111
[![CodSpeed Badge][codspeed-badge]][codspeed-url]
1212

@@ -78,6 +78,22 @@ group.bench_with_input(id, &source, |b, source| {
7878
});
7979
```
8080

81+
## Maximum Resident Set Size
82+
83+
```bash
84+
./memory.sh
85+
86+
./files/cal.com.tsx
87+
oxc 11.5 mb (1.00x)
88+
swc 16.6 mb (1.44x)
89+
biome 22.5 mb (1.95x)
90+
91+
./files/typescript.js
92+
oxc 68.8 mb (1.00x)
93+
swc 92.0 mb (1.34x)
94+
biome 117.4 mb (1.70x)
95+
```
96+
8197
## Run
8298

8399
Run the following command on your machine for replication.

memory.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cargo build --release
2+
3+
for FILE in "./files/cal.com.tsx" "./files/typescript.js"
4+
do
5+
echo $FILE
6+
7+
for APP in oxc swc biome
8+
do
9+
hyperfine --warmup 10 --show-output "/usr/bin/time -al ./target/release/$APP $FILE > /dev/null" 2>&1 | \
10+
grep "maximum resident set size" | \
11+
awk '{ print $1 }' \
12+
> ./target/output
13+
14+
TOTAL=$(awk '{ total += $1 } END { print total }' ./target/output)
15+
COUNT=$(wc -l ./target/output| awk '{ print $1 }')
16+
AVERAGE_MB=$(echo "$TOTAL $COUNT" | awk '{printf "%.1f", $1 / $2 / 1000 / 1000}')
17+
18+
echo $APP $AVERAGE_MB mb
19+
done
20+
done

src/biome.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#[global_allocator]
2+
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
3+
14
use std::{env, fs, path::Path};
25

36
use bench_parser::biome;

src/oxc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#[global_allocator]
2+
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
3+
14
use std::{env, fs, path::Path};
25

36
use bench_parser::oxc;

src/swc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#[global_allocator]
2+
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
3+
14
use std::{env, fs, path::Path};
25

36
use bench_parser::swc;
@@ -6,5 +9,5 @@ pub fn main() {
69
let path = env::args().nth(1).unwrap();
710
let path = Path::new(&path);
811
let source_text = fs::read_to_string(path).unwrap();
9-
let _ = biome::swc(path, &source_text);
12+
let _ = swc::parse(path, &source_text);
1013
}

0 commit comments

Comments
 (0)