Struct frame_counter::Frame [−][src]
Implementations
impl<'a> Frame<'a>
[src]
pub fn wait_until_framerate(&self, framerate: f64)
[src]
Waits in a hot-loop until the desired frame rate is achieved.
This function will not call std::thread:sleep
to prevent
the OS from scheduling this thread.
This means the function will consume an entire core on the CPU.
Example:
use frame_counter::FrameCounter; pub fn dummy_workload() { std::thread::sleep(std::time::Duration::from_millis(1)); } pub fn main() { let mut frame_counter = FrameCounter::default(); loop { { let frame = frame_counter.start_frame(); dummy_workload(); frame.wait_until_framerate(60f64); } println!("fps stats - {}", frame_counter); } }
pub fn sleep_until_framerate(&self, framerate: f64)
[src]
Waits in a cold-loop until the desired frame rate is achieved.
This function will call std::thread:sleep
to prevent
the process from consuming the entire CPU Core.
Example:
use frame_counter::FrameCounter; pub fn dummy_workload() { std::thread::sleep(std::time::Duration::from_millis(1)); } pub fn main() { let mut frame_counter = FrameCounter::default(); loop { { let frame = frame_counter.start_frame(); dummy_workload(); frame.sleep_until_framerate(60f64); } println!("fps stats - {}", frame_counter); } }
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Frame<'a>
impl<'a> Send for Frame<'a>
impl<'a> Sync for Frame<'a>
impl<'a> Unpin for Frame<'a>
impl<'a> !UnwindSafe for Frame<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,