notedeck: include frame history
for debugging. Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
use egui::util::History;
|
||||
|
||||
pub struct FrameHistory {
|
||||
frame_times: History<f32>,
|
||||
}
|
||||
|
||||
impl Default for FrameHistory {
|
||||
fn default() -> Self {
|
||||
let max_age: f32 = 1.0;
|
||||
let max_len = (max_age * 300.0).round() as usize;
|
||||
Self {
|
||||
frame_times: History::new(0..max_len, max_age),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FrameHistory {
|
||||
// Called first
|
||||
pub fn on_new_frame(&mut self, now: f64, previous_frame_time: Option<f32>) {
|
||||
let previous_frame_time = previous_frame_time.unwrap_or_default();
|
||||
if let Some(latest) = self.frame_times.latest_mut() {
|
||||
*latest = previous_frame_time; // rewrite history now that we know
|
||||
}
|
||||
self.frame_times.add(now, previous_frame_time); // projected
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn mean_frame_time(&self) -> f32 {
|
||||
self.frame_times.average().unwrap_or_default()
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn fps(&self) -> f32 {
|
||||
1.0 / self.frame_times.mean_time_interval().unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn _ui(&mut self, ui: &mut egui::Ui) {
|
||||
ui.label(format!(
|
||||
"Mean CPU usage: {:.2} ms / frame",
|
||||
1e3 * self.mean_frame_time()
|
||||
))
|
||||
.on_hover_text(
|
||||
"Includes egui layout and tessellation time.\n\
|
||||
Does not include GPU usage, nor overhead for sending data to GPU.",
|
||||
);
|
||||
egui::warn_if_debug_build(ui);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -13,7 +13,6 @@ mod column;
|
||||
mod deck_state;
|
||||
mod decks;
|
||||
mod draft;
|
||||
mod frame_history;
|
||||
mod key_parsing;
|
||||
pub mod login_manager;
|
||||
mod media_upload;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use notedeck_ui::colors::PINK;
|
||||
use egui::{
|
||||
Align, Button, Frame, Image, InnerResponse, Layout, RichText, ScrollArea, Ui, UiBuilder, Vec2,
|
||||
};
|
||||
use nostrdb::{Ndb, Transaction};
|
||||
use notedeck::{Accounts, Images};
|
||||
use notedeck_ui::colors::PINK;
|
||||
|
||||
use super::profile::preview::SimpleProfilePreview;
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use notedeck_ui::colors::PINK;
|
||||
use crate::relay_pool_manager::{RelayPoolManager, RelayStatus};
|
||||
use crate::ui::{Preview, PreviewConfig, View};
|
||||
use egui::{
|
||||
Align, Button, CornerRadius, Frame, Id, Image, Layout, Margin, Rgba, RichText, Ui, Vec2,
|
||||
};
|
||||
use notedeck_ui::colors::PINK;
|
||||
|
||||
use enostr::RelayPool;
|
||||
use notedeck::{Accounts, NotedeckTextStyle};
|
||||
|
||||
@@ -193,7 +193,11 @@ fn goto_top_button(center: Pos2) -> impl egui::Widget {
|
||||
});
|
||||
|
||||
let painter = ui.painter();
|
||||
painter.circle_filled(center, helper.scale_1d_pos(radius), notedeck_ui::colors::PINK);
|
||||
painter.circle_filled(
|
||||
center,
|
||||
helper.scale_1d_pos(radius),
|
||||
notedeck_ui::colors::PINK,
|
||||
);
|
||||
|
||||
let create_pt = |angle: f32| {
|
||||
let side = radius / 2.0;
|
||||
|
||||
Reference in New Issue
Block a user