17 unstable releases (5 breaking)
|new 0.6.6-alpha.1||Sep 22, 2020|
|0.6.4||Aug 27, 2020|
|0.6.2||Jul 21, 2020|
|0.4.1||Feb 25, 2020|
|0.2.0||Mar 10, 2019|
#5 in Date and time
31,334 downloads per month
Used in 18 crates (7 directly)
quanta is a high-speed timing library, useful for getting the current time very quickly.
NOTE: All conversations and contributions to this project shall adhere to the Code of Conduct.
The API documentation of this library can be found at docs.rs/quanta.
- monotonic time in nanoseconds or raw cycles
- extremely low overhead where possible
- optimized for instruction-level accuracy in measurements
- fun, science-y name!
For platforms, we have tier 1 support for Linux, Windows, and macOS/iOS. Platforms such as Solaris or various BSDs have tier 2.5 support:
quanta should work on them by virtue of depending on
libc, but we don't test or build on these platforms as all.
Architecture-wise, x86/x86-64 and SSE2 are required for the optimized TSC codepath. This is handled transparently via compile-time target features, so you must build with the appropriate compiler flags to specify the CPU features where your binary will run, as runtime detection is not supported.
Accessing the TSC on a modern x86 processor can have an overhead of as little as ~11ns, and
quanta provides the thinnest possible layer over this. Using the native time facilities, such as
clock_gettime(CLOCK_MONOTONIC) on Linux, you may expect to see closer to 17-18ns of overhead.
Measurements have not been taken for non-x86-based architectures/platforms.
The performance alone is enough to choose this over the stdlib timing facilities if you're doing performance-critical work or need high-accuracy point-in-time measurements, which
Instant is just not suitable for.
When compared to
clocksource, though, we have a few extra features that can make the difference:
Clockcan be mocked, allowing you to easily control the passage of time in your tests
endas replacements for
raw, which are optimized for instruction-level accuracy, avoiding instruction reordering that might taint measurements