pub struct NanoMonotonicClock { /* private fields */ }Expand description
A clock implementation that provides nanosecond-precision monotonic time.
This clock combines the monotonic guarantees of
MonotonicClock with the nanosecond precision
of NanoClock. It uses std::time::Instant as its time source and
stores the base time with nanosecond precision.
§Use Cases
- High-precision performance testing
- Microbenchmarking
- Scenarios requiring nanosecond-level time measurements
§Thread Safety
This type is completely thread-safe as all fields are immutable after creation.
§Examples
use prism3_clock::{NanoClock, NanoMonotonicClock};
let clock = NanoMonotonicClock::new();
let start = clock.nanos();
// Perform some operation
for _ in 0..1000 {
// Some work
}
let elapsed = clock.nanos() - start;
println!("Elapsed: {} ns", elapsed);§Author
Haixing Hu
Implementations§
Source§impl NanoMonotonicClock
impl NanoMonotonicClock
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new NanoMonotonicClock.
The clock records the current instant and system time (with nanosecond precision) as its base point. All subsequent time queries will be calculated relative to this base point.
§Returns
A new NanoMonotonicClock instance.
§Examples
use prism3_clock::NanoMonotonicClock;
let clock = NanoMonotonicClock::new();Trait Implementations§
Source§impl Clock for NanoMonotonicClock
impl Clock for NanoMonotonicClock
Source§impl Clone for NanoMonotonicClock
impl Clone for NanoMonotonicClock
Source§fn clone(&self) -> NanoMonotonicClock
fn clone(&self) -> NanoMonotonicClock
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NanoMonotonicClock
impl Debug for NanoMonotonicClock
Source§impl Default for NanoMonotonicClock
impl Default for NanoMonotonicClock
Auto Trait Implementations§
impl Freeze for NanoMonotonicClock
impl RefUnwindSafe for NanoMonotonicClock
impl Send for NanoMonotonicClock
impl Sync for NanoMonotonicClock
impl Unpin for NanoMonotonicClock
impl UnwindSafe for NanoMonotonicClock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more