Skip to content

Commit

Permalink
get rid of iter_custom because codspeed doesn't support it
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsakenHarmony committed Sep 13, 2024
1 parent 1d74d53 commit 85cb13f
Show file tree
Hide file tree
Showing 5 changed files with 312 additions and 430 deletions.
38 changes: 13 additions & 25 deletions turbopack/crates/turbo-tasks-fs/benches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ use std::{
time::{Duration, Instant},
};

use codspeed_criterion_compat::{
criterion_group, criterion_main,
measurement::{Measurement, WallTime},
BenchmarkId, Criterion,
};
use codspeed_criterion_compat::{criterion_group, criterion_main, BenchmarkId, Criterion};
use criterion::BatchSize;
use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
use tokio::runtime::Runtime;
use turbo_tasks::event::Event;
Expand Down Expand Up @@ -48,26 +45,17 @@ fn bench_file_watching(c: &mut Criterion) {
}
});

b.to_async(Runtime::new().unwrap())
.iter_custom(move |iters| {
let event = event.clone();
async move {
let m = WallTime;
let mut value = m.zero();
for _ in 0..iters {
std::thread::sleep(Duration::from_millis(1));
let l = event.listen();
let path = temp_path.join("file.txt");
let content = start.elapsed().as_micros().to_string();
let s = m.start();
fs::write(path, content).unwrap();
l.await;
let duration = m.end(s);
value = m.add(&value, &duration);
}
value
}
});
b.to_async(Runtime::new().unwrap()).iter_batched(
|| event.clone(),
|event| async move {
let l = event.listen();
let path = temp_path.join("file.txt");
let content = start.elapsed().as_micros().to_string();
fs::write(path, content).unwrap();
l.await;
},
BatchSize::SmallInput,
);

drop(watcher);
t.join().unwrap();
Expand Down
Loading

0 comments on commit 85cb13f

Please sign in to comment.