Skip to content

Commit

Permalink
fix(benchmark): sourcemap benchmark properly test `ConcatSourceMapBui…
Browse files Browse the repository at this point in the history
…lder`
  • Loading branch information
overlookmotel committed Jul 29, 2024
1 parent 58c8612 commit 436ad02
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tasks/benchmark/benches/sourcemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@ fn bench_sourcemap(criterion: &mut Criterion) {
group.bench_with_input(id, &file.source_text, |b, source_text| {
let allocator = Allocator::default();
let ret = Parser::new(&allocator, source_text, source_type).parse();

let CodegenReturn { source_text: output_txt, .. } = CodeGenerator::new()
.enable_source_map(file.file_name.as_str(), source_text)
.build(&ret.program);
let lines = output_txt.matches('\n').count() as u32;

b.iter(|| {
let CodegenReturn { source_map, source_text } = CodeGenerator::new()
let CodegenReturn { source_map, .. } = CodeGenerator::new()
.enable_source_map(file.file_name.as_str(), source_text)
.build(&ret.program);
let line = source_text.matches('\n').count() as u32;
if let Some(sourcemap) = source_map {
let mut concat_sourcemap_builder = ConcatSourceMapBuilder::default();
for i in 0..1 {
concat_sourcemap_builder.add_sourcemap(&sourcemap, line * i);
for i in 0..2 {
concat_sourcemap_builder.add_sourcemap(&sourcemap, lines * i);
}
concat_sourcemap_builder.into_sourcemap().to_json_string().unwrap();
}
Expand Down

0 comments on commit 436ad02

Please sign in to comment.