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