mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
new flamegraph and sort unstable
This commit is contained in:
parent
8193c06c8e
commit
6c437d528f
7 changed files with 23 additions and 22 deletions
|
@ -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)?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue