+pub(crate) fn cargo_command(
+ cargo: impl AsRef<Path>,
+ subcommand: &str,
+ triple: Option<&str>,
+ source_dir: &Path,
+) -> Command {
+ let mut cmd = Command::new(cargo.as_ref());
+ cmd.arg(subcommand)
+ .arg("--manifest-path")
+ .arg(source_dir.join("Cargo.toml"))
+ .arg("--target-dir")
+ .arg(source_dir.join("target"));
+
+ if let Some(triple) = triple {
+ cmd.arg("--target").arg(triple);
+ }
+
+ cmd
+}
+
+pub(crate) fn hyperfine_command(
+ warmup: u64,
+ runs: u64,
+ prepare: Option<Command>,
+ a: Command,
+ b: Command,
+) -> Command {
+ let mut bench = Command::new("hyperfine");
+
+ if warmup != 0 {
+ bench.arg("--warmup").arg(warmup.to_string());
+ }
+
+ if runs != 0 {
+ bench.arg("--runs").arg(runs.to_string());
+ }
+
+ if let Some(prepare) = prepare {
+ bench.arg("--prepare").arg(format!("{:?}", prepare));
+ }
+
+ bench.arg(format!("{:?}", a)).arg(format!("{:?}", b));
+
+ bench
+}
+