diff --git a/tasks/benchmark/benches/sourcemap.rs b/tasks/benchmark/benches/sourcemap.rs index 25c609e991b94..f3d561981d77f 100644 --- a/tasks/benchmark/benches/sourcemap.rs +++ b/tasks/benchmark/benches/sourcemap.rs @@ -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(); }