MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / execute

Method execute

src/executor/orchestrator.rs:71–183  ·  view source on GitHub ↗

Execute all benchmark targets for all configured modes, then upload results. Flattens all `(command, mode)` pairs into a single iteration: - All `Exec` targets are combined into a single exec-harness command - Each `Entrypoint` target produces its own command - Each command is crossed with every configured mode Each `(command, mode)` pair gets its own profile folder. When the user specifies `--p

(
        &self,
        setup_cache_dir: Option<&Path>,
        api_client: &mut CodSpeedAPIClient,
    )

Source from the content-addressed store, hash-verified

69 /// specifies `--profile-folder` and there are multiple pairs, deterministic
70 /// subdirectories (`<mode>-<index>`) are created under that folder.
71 pub async fn execute(
72 &self,
73 setup_cache_dir: Option<&Path>,
74 api_client: &mut CodSpeedAPIClient,
75 ) -> Result<()> {
76 // Build (command, label, uses_exec_harness) tuples while we still know the target type
77 let mut command_labels: Vec<(String, String, bool)> = vec![];
78
79 let exec_targets: Vec<&BenchmarkTarget> = self
80 .config
81 .targets
82 .iter()
83 .filter(|t| matches!(t, BenchmarkTarget::Exec { .. }))
84 .collect();
85
86 if !exec_targets.is_empty() {
87 let pipe_cmd = multi_targets::build_exec_targets_pipe_command(&exec_targets)?;
88 let label = match exec_targets.as_slice() {
89 [BenchmarkTarget::Exec { command, .. }] => {
90 format!("Running `{}` with exec-harness", command.join(" "))
91 }
92 targets => format!("Running {} commands with exec-harness", targets.len()),
93 };
94 command_labels.push((pipe_cmd, label, true));
95 }
96
97 for target in &self.config.targets {
98 if let BenchmarkTarget::Entrypoint { command, .. } = target {
99 command_labels.push((command.clone(), command.clone(), false));
100 }
101 }
102
103 struct ExecutorTarget<'a> {
104 command: String,
105 mode: &'a RunnerMode,
106 label: String,
107 uses_exec_harness: bool,
108 }
109
110 // Flatten into (command, mode) run parts
111 let modes = &self.config.modes;
112 let run_parts: Vec<ExecutorTarget> = command_labels
113 .iter()
114 .flat_map(|(cmd, label, uses_exec_harness)| {
115 modes.iter().map(move |mode| {
116 let executor_name = get_executor_from_mode(mode, None).name();
117 ExecutorTarget {
118 command: cmd.clone(),
119 mode,
120 label: format!(
121 "{} {} - {label}",
122 executor_name.icon(),
123 executor_name.label()
124 ),
125 uses_exec_harness: *uses_exec_harness,
126 }
127 })
128 })

Callers 2

execute_configFunction · 0.80
runFunction · 0.80

Calls 11

get_executor_from_modeFunction · 0.85
memtrack_pathFunction · 0.85
run_executorFunction · 0.85
lenMethod · 0.80
as_strMethod · 0.80
upload_and_pollMethod · 0.80
is_emptyMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected