1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
use std::time::{Duration, Instant, SystemTime};
/// A general statistical manager of Voxelize.
pub struct Stats {
/// The time this server started.
pub start_time: Instant,
/// Delta time of the voxelize world, in seconds.
pub delta: f32,
/// Tick of the game
pub tick: u64,
/// The time of the last tick.
pub prev_time: SystemTime,
}
impl Stats {
/// Create a new statistics instance.
pub fn new() -> Self {
Self {
delta: 0.0,
tick: 0,
start_time: Instant::now(),
prev_time: SystemTime::now(),
}
}
/// Get how long this server has been running.
pub fn elapsed(&self) -> Duration {
self.start_time.elapsed()
}
}