//! Measures the launcher-side cost of starting a game: the part we control. use std::time::Instant; fn main() { let root = dirs_root(); println!("root: {}", root.display()); // What "instant launch" skips: the round trip to Roblox before playing. let mut samples = Vec::new(); for _ in 0..5 { let t = Instant::now(); let _ = nox_roblox::deploy::latest(nox_roblox::Binary::Player, "LIVE"); samples.push(t.elapsed().as_secs_f64() * 1000.0); } samples.sort_by(|a, b| a.partial_cmp(b).unwrap()); println!( "update check (skipped by instant launch): min {:.0} ms, median {:.0} ms, max {:.0} ms", samples[0], samples[samples.len() / 2], samples[samples.len() - 1] ); // What the instant path still has to do before exec. let t = Instant::now(); let installed = nox_roblox::deploy::installed_versions(&root); let scan = t.elapsed().as_secs_f64() * 1000.0; println!("version scan: {scan:.2} ms ({} installed)", installed.len()); if let Some(v) = installed.last() { let t = Instant::now(); let plan = nox_roblox::launch::plan(&root, v, nox_roblox::Binary::Player, Some("roblox-player:1+launchmode:play")); let planning = t.elapsed().as_secs_f64() * 1000.0; println!("building the launch plan: {planning:.3} ms"); println!("would exec: {} {:?}", plan.exe.display(), plan.args); println!("total launcher-side work on the instant path: {:.2} ms", scan + planning); } } fn dirs_root() -> std::path::PathBuf { std::env::var("HOME") .map(std::path::PathBuf::from) .unwrap_or_default() .join(".local/share/noxstrap") }