Skip to content

Commit 7b4f51c

Browse files
committed
feat(runner): add experimental --cycle-estimation flag
1 parent 612399d commit 7b4f51c

5 files changed

Lines changed: 25 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ 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+
help_heading = "Experimental",
25+
env = "CODSPEED_CYCLE_ESTIMATION"
26+
)]
27+
pub cycle_estimation: bool,
1928
}
2029

2130
impl ExperimentalArgs {
@@ -25,6 +34,9 @@ impl ExperimentalArgs {
2534
if self.experimental_fair_sched {
2635
flags.push("--experimental-fair-sched");
2736
}
37+
if self.cycle_estimation {
38+
flags.push("--cycle-estimation");
39+
}
2840
flags
2941
}
3042

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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ fn get_valgrind_args(tool: &SimulationTool, config: &ExecutorConfig) -> Vec<Stri
3636

3737
match tool {
3838
SimulationTool::Callgrind => {
39+
if config.cycle_estimation {
40+
args.push("--cycle-estimation=yes".to_string());
41+
}
42+
3943
args.push("--tool=callgrind".to_string());
4044
args.push("--compress-strings=no".to_string());
4145
args.push("--combine-dumps=yes".to_string());

0 commit comments

Comments
 (0)