Skip to content

Add FrameTimeGraph: per-frame times against a budget - #575

Merged
matt-edmondson merged 5 commits into
mainfrom
claude/project-thread-wmrk2b
Sep 30, 2026
Merged

matt-edmondson merged 5 commits into
mainfrom
claude/project-thread-wmrk2b

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Before: ktsu.ImGui.Widgets had no frame-time display. A caller who wanted to see hitches drew a plain Histogram or an ImGui plot of the times, with no budget line and nothing to separate an over-budget frame from a normal one.

After: ImGuiWidgets.FrameTimeGraph draws per-frame times as bars, newest on the right, against a budget line and a second line at twice the budget. Bars over budget use the warning colour and bars over twice it use the error colour. A spike past the scale gets a cap at the top edge. Hovering a bar shows its time, rate and age. An optional row underneath reads out the average, the 99th percentile, the worst frame and the over-budget count. The widget marks itself with ImGuiProbes.MarkItem.

How:

  • It takes a span of milliseconds, or a caller-owned FrameTimeHistory ring buffer fed once a frame. It draws only as many of the newest frames as the box has pixels.
  • Histogram's bar loop moves into a shared DrawBars helper, so both widgets draw bars the same way. Histogram's output is unchanged.
  • It ships with a FrameTimeGraphDemo registered with one line in DemoSections.cs, state tests in ImGui.Widgets.Tests, an isolation suite in ImGui.Widgets.UITests, and a gallery tile.

This PR is stacked on the widget stack (#536 → #539 → #540 → #542) and targets the top of it, claude/asset-browser-026l9x, so only the FrameTimeGraph commit shows in the diff.

Closes #531

🤖 Generated with Claude Code

https://claude.ai/code/session_01MBhLQ3ZkoYk8s5tKQ8RTAP


Generated by Claude Code

FrameTimeGraph draws per-frame times as bars, newest on the right, against
a budget line and a second line at twice the budget. Bars over budget take
the warning colour, bars over twice it the error colour, and a spike past
the scale gets a cap at the top edge. Hovering a bar shows its time, rate
and age, and an optional row underneath reads out the average, 99th
percentile, worst frame and over-budget count. It takes a span of
milliseconds, or a caller-owned FrameTimeHistory ring buffer fed once a
frame, and draws only as many of the newest frames as the box has pixels.

Histogram's bar loop moves into a shared DrawBars helper so both widgets
draw bars the same way; Histogram's output is unchanged.

Closes #531

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MBhLQ3ZkoYk8s5tKQ8RTAP
@matt-edmondson matt-edmondson self-assigned this Sep 30, 2026
Base automatically changed from claude/asset-browser-026l9x to main September 30, 2026 11:28
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HgjMCJ9MQRmUk6c8KABDYH
@matt-edmondson
matt-edmondson changed the base branch from main to widget/stack-loupe September 30, 2026 11:40
Comment thread tests/ImGuiWidgetsDemo.UITests/WidgetsDemoUITests.cs Outdated
Comment thread tests/ImGuiWidgetsDemo.UITests/WidgetsDemoUITests.cs Outdated
The restack merge left five image-and-colour demo tests from the layers
below at the end of the file, so this PR's diff showed them as moved and
drew review comments on code that is not part of it. The file is now the
base's copy plus the FrameTimeGraph entry and test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MBhLQ3ZkoYk8s5tKQ8RTAP
Sonar S3358 flagged HistogramBarColors.ColorFor.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MBhLQ3ZkoYk8s5tKQ8RTAP
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HgjMCJ9MQRmUk6c8KABDYH
Base automatically changed from widget/stack-loupe to main September 30, 2026 12:44
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Domain widgets Tier 3: add FrameTimeGraph (frame-time bar graph with budget lines)

2 participants