crates/lake-product/src/bin/lake-bench.rs
//! `lake-bench <lake.wasm> <out-dir> [commit] [--cloud mock|sandbox|upcloud|scaleway]
//! [--vendor mock|sandbox|stripe|klarna|swish] [--signed <dir>]`: the Lake's whole lifecycle on
//! the ONE box's real code (see `lake_product::bench`); `--signed` is the directory
//! `cargo xtask bench lake` built the signed guests and fakes into. Exit 0 only when every step
//! passed.
fn main() -> std::process::ExitCode {
let a: Vec<String> = std::env::args().collect();
let mut positional = Vec::new();
let mut axes = lake_product::bench::Axes::default();
let mut it = a.iter().skip(1);
while let Some(w) = it.next() {
match w.as_str() {
"--cloud" => axes.cloud = it.next().cloned().unwrap_or_default(),
"--vendor" => axes.vendor = it.next().cloned().unwrap_or_default(),
"--signed" => axes.signed = it.next().map(std::path::PathBuf::from),
_ => positional.push(w.clone()),
}
}
if positional.len() < 2 {
eprintln!("usage: lake-bench <monetize_guest_lake.wasm> <out-dir> [commit] [--cloud mock|sandbox|upcloud|scaleway] [--vendor mock|sandbox|stripe|klarna|swish] [--signed <dir>]");
return std::process::ExitCode::from(2);
}
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(4)
.enable_all()
.build()
.expect("a tokio runtime");
match rt.block_on(lake_product::bench::run(
std::path::Path::new(&positional[0]),
std::path::Path::new(&positional[1]),
positional.get(2).map(String::as_str).unwrap_or("unknown"),
&axes,
)) {
Ok(p) => {
println!("bench: PASS, receipt at {}", p.display());
std::process::ExitCode::SUCCESS
}
Err(e) => {
eprintln!("bench: {e}");
std::process::ExitCode::FAILURE
}
}
}