Skip to content

Commit

Permalink
Fix bench
Browse files Browse the repository at this point in the history
  • Loading branch information
RDruon committed Aug 8, 2024
1 parent c6df20b commit ce96431
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 3 additions & 0 deletions lustre-collector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ tracing.workspace = true
[dev-dependencies]
include_dir.workspace = true
insta.workspace = true

[lib]
bench = false
12 changes: 4 additions & 8 deletions lustrefs-exporter/benches/jobstats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,24 @@ job_stats:{}"#,
str_repeat!(JOBSTAT_JOB, 1000)
);

async fn parse_synthetic_yaml(input: &'static str, len: usize) {
async fn parse_synthetic_yaml(input: &'static str) {
let f = BufReader::with_capacity(128 * 1_024, input.as_bytes());

let (fut, mut rx) = jobstats_stream(f);

let mut cnt = 0;

while rx.recv().await.is_some() {
cnt += 1;
}
while rx.recv().await.is_some() {}

fut.await.unwrap();
}

fn criterion_benchmark_fast(c: &mut Criterion) {
c.bench_function("jobstats 100", |b| {
b.to_async(tokio::runtime::Builder::new_multi_thread().build().unwrap())
.iter(|| black_box(parse_synthetic_yaml(INPUT_100_JOBS, 100)))
.iter(|| black_box(parse_synthetic_yaml(INPUT_100_JOBS)))
});
c.bench_function("jobstats 1000", |b| {
b.to_async(tokio::runtime::Builder::new_multi_thread().build().unwrap())
.iter(|| black_box(parse_synthetic_yaml(INPUT_1000_JOBS, 1000)))
.iter(|| black_box(parse_synthetic_yaml(INPUT_1000_JOBS)))
});
}
criterion_group! {
Expand Down

0 comments on commit ce96431

Please sign in to comment.