Skip to content

Commit 34e3357

Browse files
committed
feat(runner): add experimental --cycle-estimation flag
1 parent b29c40c commit 34e3357

5 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/cli/exec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ fn build_orchestrator_config(
8989
poll_results_options,
9090
extra_env: HashMap::new(),
9191
fair_sched: args.shared.experimental.experimental_fair_sched,
92+
cycle_estimation: args.shared.experimental.cycle_estimation,
9293
})
9394
}
9495

src/cli/experimental.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ pub struct ExperimentalArgs {
1616
env = "CODSPEED_EXPERIMENTAL_FAIR_SCHED"
1717
)]
1818
pub experimental_fair_sched: bool,
19+
20+
/// Enable Valgrind cycle estimation (--cycle-estimation) in simulation mode.
21+
#[arg(
22+
long,
23+
default_value_t = false,
24+
action = clap::ArgAction::Set,
25+
help_heading = "Experimental",
26+
env = "CODSPEED_CYCLE_ESTIMATION"
27+
)]
28+
pub cycle_estimation: bool,
1929
}
2030

2131
impl ExperimentalArgs {
@@ -25,6 +35,9 @@ impl ExperimentalArgs {
2535
if self.experimental_fair_sched {
2636
flags.push("--experimental-fair-sched");
2737
}
38+
if self.cycle_estimation {
39+
flags.push("--cycle-estimation");
40+
}
2841
flags
2942
}
3043

src/cli/run/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ impl RunArgs {
7878
},
7979
experimental: ExperimentalArgs {
8080
experimental_fair_sched: false,
81+
cycle_estimation: false,
8182
},
8283
},
8384
instruments: vec![],
@@ -127,6 +128,7 @@ fn build_orchestrator_config(
127128
poll_results_options,
128129
extra_env: HashMap::new(),
129130
fair_sched: args.shared.experimental.experimental_fair_sched,
131+
cycle_estimation: args.shared.experimental.cycle_estimation,
130132
})
131133
}
132134

src/executor/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ pub struct OrchestratorConfig {
9191
pub extra_env: HashMap<String, String>,
9292
/// Enable valgrind's --fair-sched option.
9393
pub fair_sched: bool,
94+
/// Enable valgrind's --cycle-estimation option.
95+
pub cycle_estimation: bool,
9496
}
9597

9698
/// Per-execution configuration passed to executors.
@@ -124,6 +126,8 @@ pub struct ExecutorConfig {
124126
pub enable_introspection: bool,
125127
/// Enable valgrind's --fair-sched option.
126128
pub fair_sched: bool,
129+
/// Enable valgrind's --cycle-estimation option.
130+
pub cycle_estimation: bool,
127131
}
128132

129133
#[derive(Debug, Clone, PartialEq)]
@@ -193,6 +197,7 @@ impl OrchestratorConfig {
193197
extra_env: self.extra_env.clone(),
194198
enable_introspection,
195199
fair_sched: self.fair_sched,
200+
cycle_estimation: self.cycle_estimation,
196201
}
197202
}
198203
}
@@ -225,6 +230,7 @@ impl OrchestratorConfig {
225230
poll_results_options: PollResultsOptions::new(false, None),
226231
extra_env: HashMap::new(),
227232
fair_sched: false,
233+
cycle_estimation: false,
228234
}
229235
}
230236
}

src/executor/valgrind/measure.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ fn get_valgrind_args(tool: &SimulationTool, config: &ExecutorConfig) -> Vec<Stri
3434
.map(|x| x.to_string())
3535
.collect();
3636

37+
args.push(format!(
38+
"--cycle-estimation={}",
39+
if config.cycle_estimation { "yes" } else { "no" }
40+
));
41+
3742
match tool {
3843
SimulationTool::Callgrind => {
3944
args.push("--tool=callgrind".to_string());

0 commit comments

Comments
 (0)