profiler stuff.

This commit is contained in:
Samuel Guerra 2021-11-07 12:42:55 -03:00
parent 5244905365
commit 9583734b36
5 changed files with 18 additions and 17 deletions

2
.gitignore vendored
View File

@ -1,7 +1,7 @@
**/target
**/*.rs.bk
**/Cargo.lock
*profile.json
profile*.json
**/*.expanded.rs
dump.*
dump*.*

View File

@ -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 {

View File

@ -801,7 +801,7 @@ impl<E: AppExtension> RunningApp<E> {
}
{
profile_scope!("extensions::init");
profile_scope!("extensions.init");
extensions.init(&mut ctx);
}
@ -1347,6 +1347,8 @@ impl<E: AppExtension> RunningApp<E> {
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<E: AppExtension> RunningApp<E> {
}
impl<E: AppExtension> Drop for RunningApp<E> {
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<ViewHeadless> {
profile_scope!("ViewProcess::open_headless");
profile_scope!("ViewProcess.open_headless");
let mut app = self.0.borrow_mut();

View File

@ -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);

View File

@ -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);