Skip to content

Commit

Permalink
fix docs issues
Browse files Browse the repository at this point in the history
Signed-off-by: Toby Lawrence <toby@nuclearfurnace.com>
  • Loading branch information
tobz committed Dec 30, 2021
1 parent 8b46f2c commit e2246c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/instant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use std::time::Duration;
/// A point-in-time wall-clock measurement.
///
/// Mimics most of the functionality of [`std::time::Instant`] but provides an additional method for
/// using the "[recent][recent]" feature of `quanta`.
///
/// [recent]:
/// using the "recent time" feature of `quanta`.
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct Instant(pub(crate) u64);

Expand All @@ -18,8 +16,10 @@ impl Instant {
/// This method depends on a lazily initialized global clock, which can take up to 200ms to
/// initialize and calibrate itself.
///
/// This method is the spiritual equivalent of [`std::time::Instant::now`]. It is guaranteed to
/// This method is the spiritual equivalent of [`Instant::now`][instant_now]. It is guaranteed to
/// return a monotonically increasing value.
///
/// [instant_now]: std::time::Instant::now
pub fn now() -> Instant {
crate::get_now()
}
Expand All @@ -30,12 +30,15 @@ impl Instant {
/// time. Instead of querying the underlying source clock directly, a shared, global value is
/// read directly without the need to scale to reference time.
///
/// The value is updated by running an "upkeep" thread or by calling [`quanta::set_recent`]. An
/// upkeep thread can be configured and spawned via [`Builder`].
/// The value is updated by running an "upkeep" thread or by calling [`set_recent`][set_recent]. An
/// upkeep thread can be configured and spawned via [`Upkeep`][upkeep].
///
/// If the upkeep thread has not been started, or no value has been set manually, a lazily
/// initialized global clock will be used to get the current time. This clock can take up to
/// 200ms to initialize and calibrate itself.
///
/// [set_recent]: crate::set_recent
/// [upkeep]: crate::Upkeep
pub fn recent() -> Instant {
crate::get_recent()
}
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
//! then the system is suspended, and then another measurement is taken, the difference between
//! those the two would not include the time the system was in suspend.
//!
//! [tsc]: https://en.wikipedia.org/wiki/Time_Stamp_Counter
//! [QueryPerformanceCounter]: https://msdn.microsoft.com/en-us/library/ms644904(v=VS.85).aspx
//! [mach_absolute_time]: https://developer.apple.com/documentation/kernel/1462446-mach_absolute_time
//! [clock_gettime]: https://linux.die.net/man/3/clock_gettime
Expand Down Expand Up @@ -485,12 +486,14 @@ impl Clock {
/// read directly without the need to scale to reference time.
///
/// The upkeep thread must be started in order to update the time. You can read the
/// documentation for [`Builder`] for more information on starting the upkeep thread, as well
/// as the details of the "current time" mechanism.
/// documentation for [`Upkeep`][upkeep] for more information on starting the upkeep thread, as
/// well as the details of the "current time" mechanism.
///
/// If the upkeep thread has not been started, the return value will be `0`.
///
/// Returns an [`Instant`].
///
/// [upkeep]: crate::Upkeep
pub fn recent(&self) -> Instant {
match &self.inner {
ClockType::Mock(mock) => Instant(mock.value()),
Expand Down

2 comments on commit e2246c4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bench-ubuntu-latest

Benchmark suite Current: e2246c4 Previous: 095747a Ratio
stdlib/instant_now 27 ns/iter (± 0) 27 ns/iter (± 0) 1
stdlib/instant_delta 60 ns/iter (± 0) 58 ns/iter (± 0) 1.03
quanta/quanta_now 27 ns/iter (± 0) 26 ns/iter (± 0) 1.04
quanta/quanta_now_delta 57 ns/iter (± 0) 56 ns/iter (± 0) 1.02
quanta/quanta_instant_now 31 ns/iter (± 0) 30 ns/iter (± 0) 1.03
quanta/quanta_raw 27 ns/iter (± 0) 26 ns/iter (± 0) 1.04
quanta/quanta_raw_scaled 27 ns/iter (± 0) 27 ns/iter (± 0) 1
quanta/quanta_raw_delta 58 ns/iter (± 0) 56 ns/iter (± 0) 1.04
quanta/quanta_start 26 ns/iter (± 0) 26 ns/iter (± 0) 1
quanta/quanta_start_scaled 27 ns/iter (± 0) 27 ns/iter (± 0) 1
quanta/quanta_end 26 ns/iter (± 0) 26 ns/iter (± 0) 1
quanta/quanta_end_scaled 27 ns/iter (± 0) 27 ns/iter (± 0) 1
quanta/quanta_start/end_delta 58 ns/iter (± 0) 56 ns/iter (± 0) 1.04
quanta/quanta_recent 2 ns/iter (± 0) 2 ns/iter (± 0) 1
quanta/quanta_instant_recent 1 ns/iter (± 0) 1 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'bench-ubuntu-latest'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 0.1.

Benchmark suite Current: e2246c4 Previous: 095747a Ratio
stdlib/instant_now 27 ns/iter (± 0) 27 ns/iter (± 0) 1
stdlib/instant_delta 60 ns/iter (± 0) 58 ns/iter (± 0) 1.03
quanta/quanta_now 27 ns/iter (± 0) 26 ns/iter (± 0) 1.04
quanta/quanta_now_delta 57 ns/iter (± 0) 56 ns/iter (± 0) 1.02
quanta/quanta_instant_now 31 ns/iter (± 0) 30 ns/iter (± 0) 1.03
quanta/quanta_raw 27 ns/iter (± 0) 26 ns/iter (± 0) 1.04
quanta/quanta_raw_scaled 27 ns/iter (± 0) 27 ns/iter (± 0) 1
quanta/quanta_raw_delta 58 ns/iter (± 0) 56 ns/iter (± 0) 1.04
quanta/quanta_start 26 ns/iter (± 0) 26 ns/iter (± 0) 1
quanta/quanta_start_scaled 27 ns/iter (± 0) 27 ns/iter (± 0) 1
quanta/quanta_end 26 ns/iter (± 0) 26 ns/iter (± 0) 1
quanta/quanta_end_scaled 27 ns/iter (± 0) 27 ns/iter (± 0) 1
quanta/quanta_start/end_delta 58 ns/iter (± 0) 56 ns/iter (± 0) 1.04
quanta/quanta_recent 2 ns/iter (± 0) 2 ns/iter (± 0) 1
quanta/quanta_instant_recent 1 ns/iter (± 0) 1 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

CC: @metrics-rs/maintainers

Please sign in to comment.