feat: add scheduler ui

This commit is contained in:
Rekai Nyangadzayi Musuka 2023-01-08 19:48:30 -06:00
parent a8fac5f3c6
commit 1d601dba39
1 changed files with 30 additions and 0 deletions

View File

@ -362,6 +362,28 @@ pub const Gui = struct {
zgui.text(" 1% Low: {:0>3} fps", .{stats[2]});
}
{
_ = zgui.begin("Scheduler", .{});
defer zgui.end();
const scheduler = cpu.sched;
zgui.text("tick: {X:0>16}", .{scheduler.tick});
zgui.separator();
const Event = std.meta.Child(@TypeOf(scheduler.queue.items));
var items: [20]Event = undefined;
const len = scheduler.queue.len;
std.mem.copy(Event, &items, scheduler.queue.items);
std.sort.sort(Event, items[0..len], {}, widgets.eventDesc(Event));
for (items[0..len]) |event| {
zgui.text("{X:0>16} | {?}", .{ event.tick, event.kind });
}
}
{
zgui.showDemoWindow(null);
}
@ -649,4 +671,12 @@ const widgets = struct {
zgui.sameLine(.{});
zgui.text("{s}", .{mode});
}
fn eventDesc(comptime T: type) fn (void, T, T) bool {
return struct {
fn inner(_: void, left: T, right: T) bool {
return left.tick > right.tick;
}
}.inner;
}
};