Move fps meter util

This commit is contained in:
Maximilian Ammann 2022-01-13 17:13:05 +01:00
parent 600a404516
commit 5cb2e93387
4 changed files with 21 additions and 5 deletions

View File

@ -1,4 +1,3 @@
mod fps_meter;
mod input;
mod platform;

View File

@ -4,6 +4,17 @@ use log::info;
use crate::platform::Instant;
/// Measures the frames per second.
///
/// # Example
/// ```rust
/// use crate::util::FPSMeter;
///
/// let mut meter = FPSMeter::new();
///
/// // call the following the the render loop
/// meter.update_and_print();
/// ```
pub struct FPSMeter {
next_report: Instant,
frame_count: u32,

View File

@ -1,11 +1,11 @@
use crate::platform::Instant;
use log::trace;
pub struct Measure {
pub struct TimeMeasure {
now: Instant,
}
impl Measure {
impl TimeMeasure {
pub fn time() -> Self {
Self {
now: Instant::now(),
@ -22,7 +22,7 @@ impl Measure {
}
}
impl Drop for Measure {
impl Drop for TimeMeasure {
fn drop(&mut self) {
self.breadcrumb("Drop");
}

View File

@ -1 +1,7 @@
pub mod measure;
//! Utils which are used internally
mod fps_meter;
mod measure;
pub use fps_meter::FPSMeter;
pub use measure::TimeMeasure;