Skip to content

Commit 4f17f19

Browse files
authored
Merge branch 'main' into perf-remove-rope
2 parents f163b59 + 7b7842a commit 4f17f19

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

benches/bench.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use rspack_sources::{
1818
};
1919

2020
use bench_complex_replace_source::{
21-
benchmark_complex_replace_source_map, benchmark_complex_replace_source_size,
21+
benchmark_complex_replace_source_map,
22+
benchmark_complex_replace_source_map_cached_source_stream_chunks,
23+
benchmark_complex_replace_source_size,
2224
benchmark_complex_replace_source_source,
2325
};
2426
use bench_source_map::{
@@ -159,6 +161,11 @@ fn bench_rspack_sources(criterion: &mut Criterion) {
159161
benchmark_complex_replace_source_map,
160162
);
161163

164+
group.bench_function(
165+
"complex_replace_source_map_cached_source_stream_chunks",
166+
benchmark_complex_replace_source_map_cached_source_stream_chunks,
167+
);
168+
162169
group.bench_function(
163170
"complex_replace_source_source",
164171
benchmark_complex_replace_source_source,

benches/bench_complex_replace_source.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ pub use criterion::*;
99
pub use codspeed_criterion_compat::*;
1010

1111
use rspack_sources::{
12-
BoxSource, MapOptions, ObjectPool, OriginalSource, ReplaceSource, SourceExt,
12+
stream_chunks::StreamChunks, BoxSource, CachedSource, MapOptions, ObjectPool,
13+
OriginalSource, ReplaceSource, Source, SourceExt,
1314
};
1415

1516
static LARGE_REPLACE_SOURCE: LazyLock<BoxSource> = LazyLock::new(|| {
@@ -36728,6 +36729,24 @@ pub fn benchmark_complex_replace_source_map(b: &mut Bencher) {
3672836729
});
3672936730
}
3673036731

36732+
pub fn benchmark_complex_replace_source_map_cached_source_stream_chunks(
36733+
b: &mut Bencher,
36734+
) {
36735+
let source = LARGE_REPLACE_SOURCE.clone();
36736+
let cached_source = CachedSource::new(source);
36737+
cached_source.map(&ObjectPool::default(), &MapOptions::default());
36738+
36739+
b.iter(|| {
36740+
black_box(cached_source.stream_chunks(
36741+
&ObjectPool::default(),
36742+
&MapOptions::default(),
36743+
&mut |_chunk, _mapping| {},
36744+
&mut |_source_index, _source, _source_content| {},
36745+
&mut |_name_index, _name| {},
36746+
));
36747+
});
36748+
}
36749+
3673136750
pub fn benchmark_complex_replace_source_source(b: &mut Bencher) {
3673236751
let source = LARGE_REPLACE_SOURCE.clone();
3673336752

benches/benchmark_repetitive_react_components.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ pub use criterion::*;
99
pub use codspeed_criterion_compat::*;
1010

1111
use rspack_sources::{
12-
BoxSource, ConcatSource, MapOptions, ObjectPool, OriginalSource,
13-
RawStringSource, ReplaceSource, ReplacementEnforce, Source, SourceExt,
14-
SourceMap, SourceMapSource, SourceMapSourceOptions,
12+
BoxSource, CachedSource, ConcatSource, MapOptions, ObjectPool,
13+
OriginalSource, RawStringSource, ReplaceSource, ReplacementEnforce, Source,
14+
SourceExt, SourceMap, SourceMapSource, SourceMapSourceOptions,
1515
};
1616

1717
static REPETITIVE_1K_REACT_COMPONENTS_SOURCE: LazyLock<BoxSource> =

0 commit comments

Comments
 (0)