Skip to content

Commit

Permalink
Add option to show performance metrics in the UI in release builds too (
Browse files Browse the repository at this point in the history
#1444)

* Add option to show performance metrics in the UI in release builds too

* Improve tooltip
  • Loading branch information
emilk authored Feb 28, 2023
1 parent 860e43d commit 8cfa784
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
22 changes: 14 additions & 8 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,9 +1055,8 @@ fn rerun_menu_button_ui(ui: &mut egui::Ui, _frame: &mut eframe::Frame, app: &mut
recordings_menu(ui, app);
});

#[cfg(debug_assertions)]
ui.menu_button("Debug", |ui| {
debug_menu(&mut app.state.app_options, ui);
ui.menu_button("Options", |ui| {
options_menu_ui(ui, &mut app.state.app_options);
});

ui.add_space(spacing);
Expand Down Expand Up @@ -1454,20 +1453,27 @@ fn recordings_menu(ui: &mut egui::Ui, app: &mut App) {
}
}

#[cfg(debug_assertions)]
fn debug_menu(options: &mut AppOptions, ui: &mut egui::Ui) {
fn options_menu_ui(ui: &mut egui::Ui, options: &mut AppOptions) {
ui.style_mut().wrap = Some(false);

if ui
.checkbox(&mut options.show_metrics, "Show metrics")
.on_hover_text("Show status bar metrics for milliseconds, ram usage, etc")
.checkbox(&mut options.show_metrics, "Show performance metrics")
.on_hover_text("Show metrics for milliseconds/frame and RAM usage in the top bar.")
.clicked()
{
ui.close_menu();
}

ui.separator();
#[cfg(debug_assertions)]
{
ui.separator();
ui.label("Debug:");
debug_menu_options_ui(ui);
}
}

#[cfg(debug_assertions)]
fn debug_menu_options_ui(ui: &mut egui::Ui) {
let mut debug = ui.style().debug;
let mut any_clicked = false;

Expand Down
3 changes: 1 addition & 2 deletions crates/re_viewer/src/misc/app_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub struct AppOptions {
pub warn_latency: f32,

/// Show milliseconds, RAM usage, etc.
#[serde(skip)] // restore to the default for the current mode (dev vs debug)
pub show_metrics: bool,
}

Expand All @@ -20,7 +19,7 @@ impl Default for AppOptions {
low_latency: 0.100,
warn_latency: 0.200,

show_metrics: cfg!(debug_assertions),
show_metrics: false,
}
}
}

0 comments on commit 8cfa784

Please sign in to comment.