Skip to content

Commit 30728f3

Browse files
committed
repetitive_react_components_map_with_warmed_pool
1 parent 941c4e0 commit 30728f3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

benches/bench.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ use benchmark_repetitive_react_components::{
3030
benchmark_repetitive_react_components_source,
3131
};
3232

33+
use crate::benchmark_repetitive_react_components::benchmark_repetitive_react_components_map_with_warmed_pool;
34+
3335
const HELLOWORLD_JS: &str = include_str!(concat!(
3436
env!("CARGO_MANIFEST_DIR"),
3537
"/benches/fixtures/transpile-minify/files/helloworld.js"
@@ -181,6 +183,11 @@ fn bench_rspack_sources(criterion: &mut Criterion) {
181183
benchmark_repetitive_react_components_map,
182184
);
183185

186+
group.bench_function(
187+
"repetitive_react_components_map_with_warmed_pool",
188+
benchmark_repetitive_react_components_map_with_warmed_pool,
189+
);
190+
184191
group.bench_function(
185192
"repetitive_react_components_source",
186193
benchmark_repetitive_react_components_source,

benches/benchmark_repetitive_react_components.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3509,6 +3509,20 @@ pub fn benchmark_repetitive_react_components_map(b: &mut Bencher) {
35093509
});
35103510
}
35113511

3512+
pub fn benchmark_repetitive_react_components_map_with_warmed_pool(
3513+
b: &mut Bencher,
3514+
) {
3515+
let source = REPETITIVE_1K_REACT_COMPONENTS_SOURCE.clone();
3516+
3517+
let object_pool = ObjectPool::default();
3518+
// Warm up the object pool to avoid measuring initialization overhead
3519+
black_box(source.map(&object_pool, &MapOptions::default()));
3520+
3521+
b.iter(|| {
3522+
black_box(source.map(&object_pool, &MapOptions::default()));
3523+
});
3524+
}
3525+
35123526
pub fn benchmark_repetitive_react_components_source(b: &mut Bencher) {
35133527
let source = REPETITIVE_1K_REACT_COMPONENTS_SOURCE.clone();
35143528

0 commit comments

Comments
 (0)