Skip to content

Commit 9a334a0

Browse files
committed
test(runner-shared): keep instrumented module event benches to 1M events
Generating and searching artifacts much larger than 1M events outlasts the CI job under the simulation and memory instruments. Pick the sizes from CODSPEED_RUNNER_MODE so these modes only search the smallest artifact, leaving walltime and plain divan runs free to cover larger ones.
1 parent c85a5ef commit 9a334a0

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

‎crates/runner-shared/benches/memtrack_reader.rs‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
//! handful of records among millions of allocation events, so the cost is
44
//! dominated by everything the search has to read past.
55
6+
use clap::ValueEnum;
67
use divan::Bencher;
78
use divan::counter::{BytesCount, ItemsCount};
89
use rand::rngs::StdRng;
910
use rand::{Rng, SeedableRng};
1011
use runner_shared::artifacts::{
1112
MemtrackArtifact, MemtrackEvent, MemtrackEventKind, StackRecord, encode_events,
1213
};
14+
use runner_shared::measurement_mode::MeasurementMode;
15+
use runner_shared::runtime_env::RUNNER_MODE_ENV;
1316
use std::io::Write;
1417

1518
fn main() {
@@ -20,20 +23,35 @@ fn main() {
2023
/// streamed decoder under the simulation instrument.
2124
const SIZES: &[usize] = &[1_000_000];
2225

26+
/// Under the simulation and memory instruments, generating and searching
27+
/// larger artifacts outlasts the CI job, so these modes only search the
28+
/// smallest artifact.
29+
const INSTRUMENTED_SIZES: &[usize] = &[1_000_000];
30+
31+
fn sizes() -> &'static [usize] {
32+
let mode = std::env::var(RUNNER_MODE_ENV)
33+
.ok()
34+
.and_then(|mode| MeasurementMode::from_str(&mode, true).ok());
35+
match mode {
36+
Some(MeasurementMode::Simulation | MeasurementMode::Memory) => INSTRUMENTED_SIZES,
37+
Some(MeasurementMode::Walltime) | None => SIZES,
38+
}
39+
}
40+
2341
#[derive(Clone, Copy)]
2442
enum Payload {
2543
Allocations,
2644
AllocationsAndStacks,
2745
}
2846

2947
/// An artifact without stack capture.
30-
#[divan::bench(args = SIZES, max_time = 10.0)]
48+
#[divan::bench(args = sizes(), max_time = 10.0)]
3149
fn find_module_events(bencher: Bencher, n: usize) {
3250
bench(bencher, n, Payload::Allocations);
3351
}
3452

3553
/// An artifact with captured stacks, which make up most of its bytes.
36-
#[divan::bench(args = SIZES, max_time = 10.0)]
54+
#[divan::bench(args = sizes(), max_time = 10.0)]
3755
fn find_module_events_with_stacks(bencher: Bencher, n: usize) {
3856
bench(bencher, n, Payload::AllocationsAndStacks);
3957
}

0 commit comments

Comments
 (0)