Skip to content

Commit af5aab5

Browse files
committed
chore: benchmark_source_map_clone
1 parent b447ca5 commit af5aab5

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

benches/bench.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ use rspack_sources::{
1717
};
1818

1919
use bench_complex_replace_source::benchmark_complex_replace_source;
20-
use bench_source_map::benchmark_parse_source_map_from_json;
20+
use bench_source_map::{
21+
benchmark_parse_source_map_from_json, benchmark_source_map_clone,
22+
};
2123

2224
const HELLOWORLD_JS: &str = include_str!(concat!(
2325
env!("CARGO_MANIFEST_DIR"),
@@ -246,10 +248,12 @@ fn bench_rspack_sources(criterion: &mut Criterion) {
246248
.bench_function("complex_replace_source", benchmark_complex_replace_source);
247249

248250
group.bench_function(
249-
"benchmark_parse_source_map_from_json",
251+
"parse_source_map_from_json",
250252
benchmark_parse_source_map_from_json,
251253
);
252254

255+
group.bench_function("source_map_clone", benchmark_source_map_clone);
256+
253257
group.finish();
254258
}
255259

benches/bench_source_map.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ pub fn benchmark_parse_source_map_from_json(b: &mut Bencher) {
1818
let _ = black_box(|| SourceMap::from_json(ANTD_MIN_JS_MAP).unwrap());
1919
})
2020
}
21+
22+
pub fn benchmark_source_map_clone(b: &mut Bencher) {
23+
let source = SourceMap::from_json(ANTD_MIN_JS_MAP).unwrap();
24+
b.iter(|| {
25+
let _ = black_box(|| source.clone());
26+
})
27+
}

0 commit comments

Comments
 (0)