run
Render one profiler frame: run target in an instrumented viewport on the
left, the devtools panels on the right. Call once per dvui frame.
Parameters
- self:*Profiler
- *Profiler
- src:std.builtin.SourceLocation
- std.builtin.SourceLocation
- target:*const fn () void
- *const fn () void
Source
Implementation
pub fn run(self: *Profiler, src: std.builtin.SourceLocation, target: *const fn () void) void {
var outer = dvui.box(src, .{ .dir = .horizontal }, .{ .expand = .both, .name = "profiler" });
defer outer.deinit();
// --- target viewport (left): time + capture only the target's tree ---
{
var viewport = dvui.box(@src(), .{ .dir = .vertical }, .{ .expand = .both, .name = "target_viewport" });
defer viewport.deinit();
const cw = dvui.currentWindow();
const t0 = cw.backend.nanoTime();
dvui.debug.captureScopeBegin(cw.gpa);
target();
dvui.debug.captureScopeEnd();
self.record(@intCast(@max(0, cw.backend.nanoTime() - t0)));
}
// --- devtools sidebar (right) ---
{
var sidebar = dvui.box(@src(), .{ .dir = .vertical }, .{
.expand = .vertical,
.min_size_content = .{ .w = 340, .h = 0 },
.background = true,
.style = .window,
.name = "devtools",
});
defer sidebar.deinit();
self.chartPanel();
self.statsPanel();
self.treePanel();
self.inspectorPanel();
}
}