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

Function build_benchmark_targets

src/cli/exec/multi_targets.rs:46–70  ·  view source on GitHub ↗

Convert project config targets into [`BenchmarkTarget`] instances. Exec targets are each converted to a `BenchmarkTarget::Exec`. Entrypoint targets are each converted to a `BenchmarkTarget::Entrypoint`.

(
    targets: &[Target],
    default_walltime: Option<&WalltimeOptions>,
)

Source from the content-addressed store, hash-verified

44/// Exec targets are each converted to a `BenchmarkTarget::Exec`.
45/// Entrypoint targets are each converted to a `BenchmarkTarget::Entrypoint`.
46pub fn build_benchmark_targets(
47 targets: &[Target],
48 default_walltime: Option<&WalltimeOptions>,
49) -> Result<Vec<BenchmarkTarget>> {
50 targets
51 .iter()
52 .map(|target| match &target.command {
53 TargetCommand::Exec { exec } => {
54 let command = shell_words::split(exec)
55 .with_context(|| format!("Failed to parse command: {exec}"))?;
56 let target_walltime = target.options.as_ref().and_then(|o| o.walltime.as_ref());
57 let walltime_args = merge_walltime_options(default_walltime, target_walltime);
58 Ok(BenchmarkTarget::Exec {
59 command,
60 name: target.name.clone(),
61 walltime_args,
62 })
63 }
64 TargetCommand::Entrypoint { entrypoint } => Ok(BenchmarkTarget::Entrypoint {
65 command: entrypoint.clone(),
66 name: target.name.clone(),
67 }),
68 })
69 .collect()
70}
71
72/// Build a shell command string that pipes BenchmarkTarget::Exec variants to exec-harness via stdin
73pub fn build_exec_targets_pipe_command(

Callers 1

runFunction · 0.85

Calls 1

merge_walltime_optionsFunction · 0.85

Tested by

no test coverage detected