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.
This commit is contained in:
waozi committed 2026-11-18 00:11:47 -03:00
1 parent d0fd254595
commit 237e86b0ae
3 files changed
+12 -4

No files matched your search

+2 -1
View File
@@ -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
+3 -1
View File
@@ -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 {
+7 -2
View File
@@ -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)
}