use std::time::Duration; use performance_profiler::{change_profiler_settings, get_profiler, time_event_mac}; fn main() { change_profiler_settings(|s| { s.active = true; s.update_interval_sec = 1.0; }); loop { update(); // prof.settings.active = false; } } #[per_macros::main_event_loop("MAIN")] fn update() { sm(32); display(); logic(); } #[per_macros::time_event("DISPLAY")] fn display() { sm(8); ui(); image(); } #[per_macros::time_event("UI")] fn ui() { sm(4); } #[per_macros::time_event("IMAGE")] fn image() { sm(18); } #[per_macros::time_event("LOGIC")] fn logic() { input(); physics(); time_event!("APPLY_INPUT", { sm(3); time_event!("INNER_1", { sm(3); time_event!("INNER_2", { sm(3); }); }); }); } #[per_macros::time_event("INPUT")] fn input() { sm(9); } #[per_macros::time_event("PHYSICS")] fn physics() { sm(19); } fn sm(mills: u64) { std::thread::sleep(Duration::from_millis(mills)); }