new flamegraph and sort unstable

This commit is contained in:
Toshit Chawda 2024-12-13 22:25:17 -08:00
parent 8193c06c8e
commit 6c437d528f
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
7 changed files with 23 additions and 22 deletions

View file

@ -30,30 +30,27 @@ fn dorewrite(data: &str) -> Result<RewriteResult> {
capture_errors: true,
do_sourcemaps: true,
scramitize: false,
scramitize: true,
strict_rewrites: true,
},
)
.context("failed to rewrite file")
}
fn dobench(data: String) {
loop {
let _ = dorewrite(&data);
}
}
fn main() -> Result<()> {
let file = env::args().nth(1).unwrap_or_else(|| "test.js".to_string());
let data = fs::read_to_string(file).context("failed to read file")?;
let bench = env::args().nth(2).is_some();
if bench {
for _ in 0..15 {
let data = data.clone();
std::thread::spawn(move || dobench(data));
let mut i = 0;
loop {
let _ = dorewrite(&data);
i += 1;
if i % 100 == 0 {
println!("{}...", i);
}
}
dobench(data);
} else {
let res = dorewrite(&data)?;