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) }