5 unstable releases
| 0.3.2 | Mar 6, 2025 |
|---|---|
| 0.3.1 | Dec 17, 2024 |
| 0.3.0 | Dec 17, 2024 |
| 0.2.0 | Dec 17, 2024 |
| 0.1.0 | Sep 12, 2024 |
#702 in Date and time
16,038 downloads per month
Used in 4 crates
(via libsw)
63KB
994 lines
libsw_core is a comprehensive stopwatch implementation.
It offers checked stopping and arithmetic, precise control over when operations occur, and supports arbitrary timekeeping types.
If you want to do benchmarking, please use something like Criterion.
Introduction
libsw_core provides the Stopwatch type.
This implementation is agnostic to the timekeeping type used, by
virtue of being generic. Any type I that implements the Instant
trait (as in Stopwatch<I>) can be used for timekeeping.
Instant is implemented for several timekeeping types out of the box (see
features). If present, these
implementations are exposed as type aliases.
Features
| Name | Implies | Description |
|---|---|---|
default |
Enabled by default. | |
std |
Depends on the standard library. Implements Instant for std::time::{Instant, SystemTime}. Exposes Sw and SystemSw type aliases. |
|
tokio |
std |
Implements Instant for tokio::time::Instant. Exposes TokioSw type alias. |
coarsetime |
std |
Implements Instant for coarsetime::Instant. Exposes CoarseSw type alias. |
quanta |
std |
Implements Instant for quanta::Instant. Exposes QuantaSw type alias. |
time |
std |
Deprecated. Implements Instant for time::Instant. Exposes TimeSw type alias. |
no_std support
#![no_std] is set by default.
Compiler support
Standalone, the minimum supported version of Rust is 1.61.0.
Adding dependencies may bump this.
Safety
libsw_core contains no unsafe code (#![forbid(unsafe_code)]).
libsw (core)
libsw_core is a comprehensive and safe stopwatch implementation.
The minimum supported version of Rust is 1.61.0.
License
Dual licensed under the MIT or Apache 2.0 licenses.
Dependencies
~0–11MB
~93K SLoC