forked from 1b-agent/opencadstudio-upstream
perf: measure widget-tree construction
Everything measured so far accounts for about 1 ms of a ~120 ms pan frame: update is 5-28 ms at worst and usually far less, prepare 0.45 ms, encode 0.5 ms. Meanwhile the GPU idles at 0-8%, encoding no scene at all leaves latency unchanged, major page faults stay flat at 17 across forty seconds of panning, and freeing 6 GB of swap changes nothing either. So the time is in code that has never been timed. `view()` runs between the input handler returning and `prepare` being called, rebuilds the whole widget tree every frame, and is the largest unmeasured span in that gap. Reports only when it exceeds 1 ms, so a healthy frame stays quiet. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2787dcc1a3
commit
15425298b7
1 file changed
+14
-1
+14
-1
@@ -192,7 +192,20 @@ impl OpenCADStudio {
|
|||||||
// All dialogs are in-canvas modals now (Plan B); view_main stacks the
|
// All dialogs are in-canvas modals now (Plan B); view_main stacks the
|
||||||
// active one. `window_id` is unused — there is only the main window.
|
// active one. `window_id` is unused — there is only the main window.
|
||||||
let _ = window_id;
|
let _ = window_id;
|
||||||
self.view_main()
|
// Pan latency on a large drawing is ~120 ms while `update`, `prepare`
|
||||||
|
// and `encode` together account for ~1 ms of it, the GPU sits at 0-8%,
|
||||||
|
// and encoding no scene at all changes nothing. Widget-tree
|
||||||
|
// construction is the largest span between the input handler returning
|
||||||
|
// and `prepare` running, and it was never measured.
|
||||||
|
let started = crate::perf::enabled().then(iced::time::Instant::now);
|
||||||
|
let element = self.view_main();
|
||||||
|
if let Some(started) = started {
|
||||||
|
let elapsed_ms = started.elapsed().as_secs_f64() * 1000.0;
|
||||||
|
if elapsed_ms >= 1.0 {
|
||||||
|
crate::perf_record!("[perf] view {:>7.1}ms", elapsed_ms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
element
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The primary window: viewport, ribbon, tab bar, status bar. Split out of
|
/// The primary window: viewport, ribbon, tab bar, status bar. Split out of
|
||||||
|
|||||||
Reference in new issue
Block a user