Merge pull request #1073 from mechpanos/pr/edit-latency-metric

This commit is contained in:
Hakan Seven committed 2026-09-08 17:17:37 +03:00
commit 2ba5415479
3 files changed
+38 -1

No files matched your search

+19
View File
@@ -1432,6 +1432,10 @@ pub(crate) enum NavPerfOp {
Pan,
Zoom,
Rotate,
/// A message that changed geometry. Reported through the same line as
/// navigation because the question is the same one: how long from the
/// input to the frame that answers it.
Edit,
}
impl NavPerfOp {
@@ -1440,6 +1444,7 @@ impl NavPerfOp {
Self::Pan => "pan",
Self::Zoom => "zoom",
Self::Rotate => "rotate",
Self::Edit => "edit",
}
}
}
@@ -1447,6 +1452,10 @@ impl NavPerfOp {
#[derive(Clone, Copy, Debug)]
pub(in crate::scene) struct NavPerfSample {
pub(in crate::scene) op: NavPerfOp,
/// Which message caused it. An edit whose handler runs in under a
/// millisecond never reaches the `update` line's threshold, so without this
/// the log shows the latency but not what asked for it.
pub(in crate::scene) cause: &'static str,
pub(in crate::scene) space: &'static str,
pub(in crate::scene) mode: &'static str,
pub(in crate::scene) started: iced::time::Instant,
@@ -2875,6 +2884,15 @@ impl Scene {
}
pub(crate) fn record_nav_perf(&self, op: NavPerfOp, started: iced::time::Instant) {
self.record_nav_perf_caused(op, "-", started);
}
pub(crate) fn record_nav_perf_caused(
&self,
op: NavPerfOp,
cause: &'static str,
started: iced::time::Instant,
) {
if !crate::perf::enabled() {
return;
}
@@ -2887,6 +2905,7 @@ impl Scene {
};
self.nav_perf_pending.set(Some(NavPerfSample {
op,
cause,
space,
mode,
started,
+2 -1
View File
@@ -1216,8 +1216,9 @@ impl shader::Primitive for Primitive {
let prepare_ms = nav_prepare_started.elapsed().as_secs_f64() * 1000.0;
if let Some(sample) = self.nav_perf {
crate::perf::record(format_args!(
"[perf] nav-prepare op={} space={} mode={} input={:.2}ms build={:.2}ms prepare={:.2}ms elapsed={:.2}ms viewports={}",
"[perf] nav-prepare op={} cause={} space={} mode={} input={:.2}ms build={:.2}ms prepare={:.2}ms elapsed={:.2}ms viewports={}",
sample.op.label(),
sample.cause,
sample.space,
sample.mode,
sample.input_ms,