Skip to content

Commit 595644f

Browse files
chore: run multi thread test cases in codspeed (#76)
Co-authored-by: CPunisher <1343316114@qq.com>
1 parent e904259 commit 595644f

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

benches/resolver.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88
path::{Path, PathBuf},
99
sync::Arc,
1010
};
11-
use tokio::runtime;
11+
use tokio::runtime::{self, Builder};
1212
use tokio::task::JoinSet;
1313

1414
fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> io::Result<()> {
@@ -134,6 +134,14 @@ fn bench_resolver(c: &mut Criterion) {
134134

135135
let mut group = c.benchmark_group("resolver");
136136

137+
// codspeed can only handle to up to 500 threads
138+
let multi_rt = || {
139+
Builder::new_multi_thread()
140+
.max_blocking_threads(256)
141+
.build()
142+
.expect("failed to create tokio runtime")
143+
};
144+
137145
// force to use four threads
138146
rayon::ThreadPoolBuilder::new()
139147
.num_threads(4)
@@ -157,9 +165,8 @@ fn bench_resolver(c: &mut Criterion) {
157165
);
158166
});
159167

160-
#[cfg(not(feature = "codspeed"))]
161168
group.bench_with_input(BenchmarkId::from_parameter("multi-thread"), &data, |b, data| {
162-
let runner = runtime::Runtime::new().expect("failed to create tokio runtime");
169+
let runner = multi_rt();
163170
let oxc_resolver = Arc::new(oxc_resolver());
164171

165172
b.iter_with_setup(
@@ -208,12 +215,11 @@ fn bench_resolver(c: &mut Criterion) {
208215
},
209216
);
210217

211-
#[cfg(not(feature = "codspeed"))]
212218
group.bench_with_input(
213219
BenchmarkId::from_parameter("resolve from symlinks multi thread"),
214220
&symlinks_range,
215221
|b, data| {
216-
let runner = runtime::Runtime::new().expect("failed to create tokio runtime");
222+
let runner = multi_rt();
217223
let oxc_resolver = Arc::new(oxc_resolver());
218224

219225
let symlink_test_dir = symlink_test_dir.clone();

0 commit comments

Comments
 (0)