From 237e86b0aec30d0e2e3a1baa4bd02ae0a32d3302 Mon Sep 17 00:00:00 2001 From: Waozi Date: Wed, 18 Nov 2026 00:11:47 -0300 Subject: [PATCH] Flush the figure preview's timing report as it runs The live window now reports every 120 painted frames and once more when it closes, flushing each report, so a launcher's journal shows it even for a short run. --- design/figure-preview/README.md | 3 ++- design/figure-preview/figure_preview.zi | 4 +++- design/figure-preview/preview_profile.zi | 9 +++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/design/figure-preview/README.md b/design/figure-preview/README.md index aa7461878..97fc43489 100644 --- a/design/figure-preview/README.md +++ b/design/figure-preview/README.md @@ -51,7 +51,8 @@ downward dog, the Workout's lowest squat and lunge, and the astral exits. ## Profiling The window prints a timing report to its standard output (the launcher's -journal) every 240 painted frames: median and 95th percentile milliseconds +journal) every 120 painted frames and when it closes: median and 95th +percentile milliseconds over the last 240 frames for the whole frame and for each step (the practice's pose solve, the figure's pose, skinning, cloth, render and readback, finish and ground shadow, the backdrop, compositing, the astral double, the texture upload diff --git a/design/figure-preview/figure_preview.zi b/design/figure-preview/figure_preview.zi index 7298a1f70..990bcc2f0 100644 --- a/design/figure-preview/figure_preview.zi +++ b/design/figure-preview/figure_preview.zi @@ -126,7 +126,9 @@ main :: (argc: s32, argv: **u8) -> s32 { if argc >= 3 && TextFromCString(argv[1]) == "--capture" { return PreviewCapture(*preview_media, *preview_backdrops, *preview_library, TextFromCString(argv[2])) } - return Desktop.RunTitled(PreviewDraw, 1360, 900, "Figure preview") + status := Desktop.RunTitled(PreviewDraw, 1360, 900, "Figure preview") + PreviewProfileReport("live window, closing") + return status } PreviewDraw :: (session: Session, viewport: Rectangle) -> s32 { diff --git a/design/figure-preview/preview_profile.zi b/design/figure-preview/preview_profile.zi index 228c204a1..1a0647c75 100644 --- a/design/figure-preview/preview_profile.zi +++ b/design/figure-preview/preview_profile.zi @@ -1,9 +1,13 @@ // Frame-time profiling for the figure preview: each phase of the last 240 // frames, reported as median and 95th percentile milliseconds. The live -// window prints a report every 240 frames; `--profile` measures without one. +// window prints a report every 120 frames and when it closes; `--profile` +// measures without one. #import "std/math" Timer :: #import "std/timer_linux"; +libc :: #system_library "libc"; +PreviewFlushOutput :: (stream: *void) -> s32 #foreign libc "fflush"; + PREVIEW_PHASE_FRAME :: 0 PREVIEW_PHASE_SOLVE :: 1 PREVIEW_PHASE_POSE :: 2 @@ -46,7 +50,7 @@ PreviewRecord :: (phase: s32, milliseconds: float64) { // Ends a frame; LABEL names the run, and a full window of frames prints. PreviewProfileFrame :: (label: string) { preview_profile.frames += 1 - if preview_profile.frames % PREVIEW_PROFILE_FRAMES == 0 { + if preview_profile.frames % (PREVIEW_PROFILE_FRAMES / 2) == 0 { PreviewProfileReport(label) } } @@ -75,4 +79,5 @@ PreviewProfileReport :: (label: string) { print(" %=%/%", names[phase], cast(s64)(median * 10.0 + 0.5), cast(s64)(tail * 10.0 + 0.5)) } print(" (tenths of a ms)\n") + unused PreviewFlushOutput(null) }