Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}
}
}