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

Function perform

crates/exec-harness/src/walltime/mod.rs:17–67  ·  view source on GitHub ↗
(commands: Vec<BenchmarkCommand>)

Source from the content-addressed store, hash-verified

15use crate::uri::generate_name_and_uri;
16
17pub fn perform(commands: Vec<BenchmarkCommand>) -> Result<()> {
18 let mut walltime_benchmarks = Vec::with_capacity(commands.len());
19
20 for cmd in commands {
21 let name_and_uri = generate_name_and_uri(&cmd.name, &cmd.command);
22 name_and_uri.print_executing();
23 let execution_options: ExecutionOptions = cmd.walltime_args.try_into()?;
24
25 let NameAndUri {
26 name: bench_name,
27 uri: bench_uri,
28 ..
29 } = name_and_uri;
30
31 let times_per_round_ns =
32 benchmark_loop::run_rounds(bench_uri.clone(), cmd.command, &execution_options)?;
33
34 // Collect walltime results
35 let max_time_ns = times_per_round_ns.iter().copied().max();
36
37 let walltime_benchmark = WalltimeBenchmark::from_runtime_data(
38 bench_name.clone(),
39 bench_uri.clone(),
40 vec![1; times_per_round_ns.len()],
41 times_per_round_ns,
42 max_time_ns,
43 );
44
45 walltime_benchmarks.push(walltime_benchmark);
46 }
47
48 let walltime_results = WalltimeResults::new(
49 Creator {
50 name: INTEGRATION_NAME.to_string(),
51 version: INTEGRATION_VERSION.to_string(),
52 pid: std::process::id(),
53 },
54 walltime_benchmarks,
55 )
56 .expect("Failed to create walltime results");
57
58 walltime_results
59 .save_to_file(
60 std::env::var("CODSPEED_PROFILE_FOLDER")
61 .map(std::path::PathBuf::from)
62 .unwrap_or_else(|_| std::env::current_dir().unwrap().join(".codspeed")),
63 )
64 .context("Failed to save walltime results")?;
65
66 Ok(())
67}
68
69#[cfg(test)]
70mod tests;

Callers 1

execute_benchmarksFunction · 0.50

Calls 4

generate_name_and_uriFunction · 0.85
run_roundsFunction · 0.85
print_executingMethod · 0.80
save_to_fileMethod · 0.80

Tested by

no test coverage detected