Crate libsw_core

Source
Expand description

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

NameImpliesDescription
defaultEnabled by default.
stdDepends on the standard library. Implements Instant for std::time::{Instant, SystemTime}. Exposes Sw and SystemSw type aliases.
tokiostdImplements Instant for tokio::time::Instant. Exposes TokioSw type alias.
coarsetimestdImplements Instant for coarsetime::Instant. Exposes CoarseSw type alias.
quantastdImplements Instant for quanta::Instant. Exposes QuantaSw type alias.
timestdDeprecated. 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)]).

Structs§

Stopwatch
A stopwatch measures and accumulates elapsed time between starts and stops.

Traits§

Instant
A trait outlining the behavior of a timekeeping type.

Type Aliases§

CoarseSwcoarsetime
Alias to Stopwatch using the coarsetime crate’s Instant type.
QuantaSwquanta
Alias to Stopwatch using the quanta crate’s Instant type.
Swstd
Alias to Stopwatch using the standard library’s Instant type.
SystemSwstd
Alias to Stopwatch using the standard library’s SystemTime type.
TimeSwDeprecatedtime
Alias to Stopwatch using the time crate’s Instant type.
TokioSwtokio
Alias to Stopwatch using Tokio’s Instant type.