Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion tasks/benchmark/benches/minifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::Path;

use oxc_allocator::Allocator;
use oxc_benchmark::{BenchmarkId, Criterion, criterion_group, criterion_main};
use oxc_mangler::Mangler;
use oxc_mangler::{MangleOptions, MangleOptionsKeepNames, Mangler};
use oxc_minifier::{CompressOptions, Compressor};
use oxc_parser::Parser;
use oxc_semantic::SemanticBuilder;
Expand Down Expand Up @@ -71,6 +71,32 @@ fn bench_mangler(criterion: &mut Criterion) {
});
});
}

{
let files = TestFiles::minimal();
let first_file = files.files().first().unwrap();
let id = BenchmarkId::from_parameter(format!("{}_keep_names", &first_file.file_name));
let source_type = SourceType::from_path(&first_file.file_name).unwrap();
let source_text = first_file.source_text.as_str();
let allocator = Allocator::default();
let temp_allocator = Allocator::default();
group.bench_function(id, |b| {
b.iter_with_setup_wrapper(|runner| {
let program = Parser::new(&allocator, source_text, source_type).parse().program;
let mut semantic = SemanticBuilder::new().build(&program).semantic;
runner.run(|| {
Mangler::new_with_temp_allocator(&temp_allocator)
.with_options(MangleOptions {
top_level: false,
keep_names: MangleOptionsKeepNames::all_true(),
debug: false,
})
.build_with_semantic(&mut semantic, &program);
});
});
});
}

group.finish();
}

Expand Down
Loading