//! Bounded run of the production desktop host, with normal teardown for metrics. //! No machine timing or rendering loop is replaced by this measurement harness. use prometeu_host_desktop_winit::{audio, fs_backend, log_sink, stats, utilities, wall_clock}; #[allow(dead_code)] #[path = "../src/debugger.rs"] mod debugger; #[path = "../src/input.rs"] mod input; #[path = "../src/presentation_blit.rs"] mod presentation_blit; #[allow(dead_code)] #[path = "../src/studio/mod.rs"] mod studio; #[path = "../src/viewport.rs"] mod viewport; // Compile the actual host implementation; its non-desktop entry points are unused // by this executable. Keep measurement access out of the product's public API. #[allow(dead_code)] mod runner { include!("../src/runner.rs"); impl HostRunner { pub(super) fn measured_state(&mut self) -> serde_json::Value { serde_json::json!({ "host_vm_ticks": self.firmware.os.vm().tick_index(), "completed_vm_frames": self.firmware.os.vm().completed_logical_frames(), "logical_frame_index": self.firmware.os.vm().logical_frame_index(), "synchronous_publications": self.firmware.os.vm().telemetry_snapshot().presented_frames, "front_buffer_publications": self.hardware.gfx.publication_count(), "physical_display_hz": null, }) } } } use std::time::{Duration, Instant}; use winit::{ application::ApplicationHandler, event::WindowEvent, event_loop::{ActiveEventLoop, EventLoop}, window::WindowId, }; struct Measure { runner: runner::HostRunner, started: Option, duration: Duration, } impl ApplicationHandler for Measure { fn resumed(&mut self, events: &ActiveEventLoop) { self.runner.resumed(events); self.started = Some(Instant::now()); } fn window_event(&mut self, events: &ActiveEventLoop, id: WindowId, event: WindowEvent) { self.runner.window_event(events, id, event); } fn about_to_wait(&mut self, events: &ActiveEventLoop) { if self.started.is_some_and(|start| start.elapsed() >= self.duration) { events.exit(); } else { self.runner.about_to_wait(events); } } } fn main() -> Result<(), Box> { let path = std::env::args().nth(1).expect("cartridge directory"); let seconds: u64 = std::env::args().nth(2).map(|s| s.parse().expect("seconds")).unwrap_or(10); assert!(seconds > 0); let mut runner = runner::HostRunner::new(None, None); runner.set_boot_target(prometeu_firmware::BootTarget::Cartridge { path, debug: false, debug_port: 0, }); let mut app = Measure { runner, started: None, duration: Duration::from_secs(seconds) }; let mut events = EventLoop::builder(); #[cfg(target_os = "macos")] { use winit::platform::macos::EventLoopBuilderExtMacOS; events.with_activate_ignoring_other_apps(true); } events.build()?.run_app(&mut app)?; println!( "{}", serde_json::json!({"schema":1,"source":"production_desktop_host", "elapsed_seconds":app.started.map(|s|s.elapsed().as_secs_f64()), "state":app.runner.measured_state(), "limitation":"includes boot, no discarded warmup; host/API submission is not physical scanout"}) ); Ok(()) }