Skip to content

Commit

Permalink
refactor(es/minifier): Make minify-all profilable (#9888)
Browse files Browse the repository at this point in the history
**Description:**

I modified it to minify 10 times so I can profile it.
  • Loading branch information
kdy1 authored Jan 16, 2025
1 parent 197f0bc commit fbad136
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions crates/swc_ecma_minifier/examples/minify-all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ fn main() {
let files = expand_dirs(dirs);
eprintln!("Using {} files", files.len());

let start = Instant::now();
minify_all(files);

eprintln!("Took {:?}", start.elapsed());
for i in 0..10 {
let start = Instant::now();
minify_all(&files);
eprintln!("{}: Took {:?}", i, start.elapsed());
}
}

/// Return the whole input files as abolute path.
Expand Down Expand Up @@ -65,11 +66,11 @@ impl Parallel for Worker {
}

#[inline(never)] // For profiling
fn minify_all(files: Vec<PathBuf>) {
fn minify_all(files: &[PathBuf]) {
GLOBALS.set(&Default::default(), || {
Worker.maybe_par(2, files, |_, path| {
testing::run_test(false, |cm, handler| {
let fm = cm.load_file(&path).expect("failed to load file");
let fm = cm.load_file(path).expect("failed to load file");

let unresolved_mark = Mark::new();
let top_level_mark = Mark::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_minifier/src/util/base54.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl Visit for CharFreqAnalyzer<'_> {
visit_obj_and_computed!();

fn visit_ident(&mut self, i: &Ident) {
if i.sym != "arguments" && i.ctxt == self.unresolved_ctxt {
if i.ctxt == self.unresolved_ctxt && i.sym != "arguments" {
return;
}

Expand Down

0 comments on commit fbad136

Please sign in to comment.