diff --git a/.gitignore b/.gitignore index 158090a0c..a55e1cf2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ **/target **/*.rs.bk **/Cargo.lock -*profile.json +profile*.json **/*.expanded.rs dump.* dump*.* diff --git a/examples/gradient.rs b/examples/gradient.rs index 9f6d83d2f..ff40c24fc 100644 --- a/examples/gradient.rs +++ b/examples/gradient.rs @@ -1,7 +1,6 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] use zero_ui::prelude::*; -use zero_ui::properties::events::widget::on_deinit; use zero_ui_view_prebuilt as zero_ui_view; fn main() { @@ -30,12 +29,11 @@ fn app_main() { ]; }; }; - #[cfg(feature = "app_profiler")] - on_deinit = hn!(|_, _| { - zero_ui::core::profiler::write_profile("resize-profile.json", false); - }); } - }) + }); + + #[cfg(feature = "app_profiler")] + zero_ui::core::profiler::write_profile("profile-gradient.json", false); } fn title(title: &'static str) -> impl Widget { diff --git a/zero-ui-core/src/app.rs b/zero-ui-core/src/app.rs index 1edbb0332..a50dbb81d 100644 --- a/zero-ui-core/src/app.rs +++ b/zero-ui-core/src/app.rs @@ -801,7 +801,7 @@ impl RunningApp { } { - profile_scope!("extensions::init"); + profile_scope!("extensions.init"); extensions.init(&mut ctx); } @@ -1347,6 +1347,8 @@ impl RunningApp { profile_scope!("events"); for event in u.events { + profile_scope!("{:?}", event); + self.extensions.event_preview(&mut ctx, &event); observer.event_preview(&mut ctx, &event); Events::on_pre_events(&mut ctx, &event); @@ -1404,6 +1406,7 @@ impl RunningApp { } impl Drop for RunningApp { fn drop(&mut self) { + profile_scope!("extensions.deinit"); let mut ctx = self.owned_ctx.borrow(); self.extensions.deinit(&mut ctx); } @@ -2080,7 +2083,7 @@ pub mod view_process { /// Open a window and associate it with the `window_id`. pub fn open_window(&self, config: WindowRequest) -> Result<(ViewWindow, WindowOpenData)> { - profile_scope!("ViewProcess::open_window"); + profile_scope!("ViewProcess.open_window"); let mut app = self.0.borrow_mut(); let _ = app.check_generation(); @@ -2104,7 +2107,7 @@ pub mod view_process { /// Note that no actual window is created, only the renderer, the use of window-ids to identify /// this renderer is only for convenience. pub fn open_headless(&self, config: HeadlessRequest) -> Result { - profile_scope!("ViewProcess::open_headless"); + profile_scope!("ViewProcess.open_headless"); let mut app = self.0.borrow_mut(); diff --git a/zero-ui-core/src/debug.rs b/zero-ui-core/src/debug.rs index 9b82fde51..3003e81b8 100644 --- a/zero-ui-core/src/debug.rs +++ b/zero-ui-core/src/debug.rs @@ -673,7 +673,7 @@ impl UiNode for PropertyInfoNode { } fn render(&self, ctx: &mut RenderContext, frame: &mut FrameBuilder) { - profile_scope!("{}::render", self.info.borrow().property_name); + profile_scope!("{}.render", self.info.borrow().property_name); let t = Instant::now(); self.child.render(ctx, frame); diff --git a/zero-ui-core/src/window.rs b/zero-ui-core/src/window.rs index 19e2ba67a..c2035479d 100644 --- a/zero-ui-core/src/window.rs +++ b/zero-ui-core/src/window.rs @@ -1901,12 +1901,12 @@ impl AppWindow { fn on_update(&mut self, ctx: &mut AppContext) { if self.first_update { - profile_scope!("window({})::on_update::init", self.id.sequential()); + profile_scope!("window({}).on_update-init", self.id.sequential()); self.context.init(ctx); self.first_update = false; } else { - profile_scope!("window({})::on_update", self.id.sequential()); + profile_scope!("window({}).on_update", self.id.sequential()); self.context.update(ctx); @@ -2141,7 +2141,7 @@ impl AppWindow { return; } - profile_scope!("window({})::on_layout", self.id.sequential()); + profile_scope!("window({}).on_layout", self.id.sequential()); // layout using the "system" size, it can still be overwritten by auto_size. let (size, _, _) = self.layout_size(ctx, true); @@ -2167,7 +2167,7 @@ impl AppWindow { fn on_init_layout(&mut self, ctx: &mut AppContext) { debug_assert!(self.first_layout); - profile_scope!("window({})::on_init_layout", self.id.sequential()); + profile_scope!("window({}).on_init_layout", self.id.sequential()); self.first_layout = false; @@ -2501,7 +2501,7 @@ impl AppWindow { return; } - profile_scope!("window({})::on_render", self.id.sequential()); + profile_scope!("window({}).on_render", self.id.sequential()); let frame = self.render_frame(ctx); @@ -2519,7 +2519,7 @@ impl AppWindow { return; } - profile_scope!("window({})::on_render_update", self.id.sequential()); + profile_scope!("window({}).on_render_update", self.id.sequential()); let capture_image = self.take_capture_image(ctx.vars);