Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ use rspack_sources::{
};

use bench_complex_replace_source::{
benchmark_complex_replace_source_map, benchmark_complex_replace_source_size,
benchmark_complex_replace_source_map,
benchmark_complex_replace_source_map_cached_source_stream_chunks,
benchmark_complex_replace_source_size,
benchmark_complex_replace_source_source,
};
use bench_source_map::{
Expand Down Expand Up @@ -159,6 +161,11 @@ fn bench_rspack_sources(criterion: &mut Criterion) {
benchmark_complex_replace_source_map,
);

group.bench_function(
"complex_replace_source_map_cached_source_stream_chunks",
benchmark_complex_replace_source_map_cached_source_stream_chunks,
);

group.bench_function(
"complex_replace_source_source",
benchmark_complex_replace_source_source,
Expand Down
21 changes: 20 additions & 1 deletion benches/bench_complex_replace_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ pub use criterion::*;
pub use codspeed_criterion_compat::*;

use rspack_sources::{
BoxSource, MapOptions, ObjectPool, OriginalSource, ReplaceSource, SourceExt,
stream_chunks::StreamChunks, BoxSource, CachedSource, MapOptions, ObjectPool,
OriginalSource, ReplaceSource, Source, SourceExt,
};

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

pub fn benchmark_complex_replace_source_map_cached_source_stream_chunks(
b: &mut Bencher,
) {
let source = LARGE_REPLACE_SOURCE.clone();
let cached_source = CachedSource::new(source);
cached_source.map(&ObjectPool::default(), &MapOptions::default());

b.iter(|| {
black_box(cached_source.stream_chunks(
&ObjectPool::default(),
&MapOptions::default(),
&mut |_chunk, _mapping| {},
&mut |_source_index, _source, _source_content| {},
&mut |_name_index, _name| {},
));
});
}

pub fn benchmark_complex_replace_source_source(b: &mut Bencher) {
let source = LARGE_REPLACE_SOURCE.clone();

Expand Down
6 changes: 3 additions & 3 deletions benches/benchmark_repetitive_react_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ pub use criterion::*;
pub use codspeed_criterion_compat::*;

use rspack_sources::{
BoxSource, ConcatSource, MapOptions, ObjectPool, OriginalSource,
RawStringSource, ReplaceSource, ReplacementEnforce, Source, SourceExt,
SourceMap, SourceMapSource, SourceMapSourceOptions,
BoxSource, CachedSource, ConcatSource, MapOptions, ObjectPool,
OriginalSource, RawStringSource, ReplaceSource, ReplacementEnforce, Source,
SourceExt, SourceMap, SourceMapSource, SourceMapSourceOptions,
};

static REPETITIVE_1K_REACT_COMPONENTS_SOURCE: LazyLock<BoxSource> =
Expand Down