Start profiler UI/thread

This commit is contained in:
2025-08-27 22:49:44 -04:00
parent 38b34c9cf9
commit 3bfdcc9366
8 changed files with 218 additions and 54 deletions
+5
View File
@@ -228,6 +228,11 @@ impl GameWindow {
.send_event(UserEvent::OpenTerminal(self.sim_id))
.unwrap();
}
if ui.button("Profiler").clicked() {
self.proxy
.send_event(UserEvent::OpenProfiler(self.sim_id))
.unwrap();
}
if ui.button("GDB Server").clicked() {
self.proxy
.send_event(UserEvent::OpenDebugger(self.sim_id))
+54
View File
@@ -0,0 +1,54 @@
use egui::{CentralPanel, ViewportBuilder, ViewportId};
use crate::{
emulator::{EmulatorClient, SimId},
profiler::Profiler,
window::AppWindow,
};
pub struct ProfileWindow {
sim_id: SimId,
profiler: Profiler,
}
impl ProfileWindow {
pub fn new(sim_id: SimId, client: EmulatorClient) -> Self {
Self {
sim_id,
profiler: Profiler::new(sim_id, client),
}
}
pub fn launch(&mut self) {
self.profiler.start();
}
}
impl AppWindow for ProfileWindow {
fn viewport_id(&self) -> ViewportId {
ViewportId::from_hash_of(format!("Profile-{}", self.sim_id))
}
fn sim_id(&self) -> SimId {
self.sim_id
}
fn initial_viewport(&self) -> ViewportBuilder {
ViewportBuilder::default()
.with_title(format!("Profiler ({})", self.sim_id))
.with_inner_size((300.0, 200.0))
}
fn show(&mut self, ctx: &egui::Context) {
CentralPanel::default().show(ctx, |ui| {
let mut started = self.profiler.started();
if ui.checkbox(&mut started, "Profiling enabled?").changed() {
if started {
self.profiler.start();
} else {
self.profiler.stop();
}
}
});
}
}