Tempus Fugit
This is a Rust crate that operates around the concept of measuring the time it takes to take some action.
Convenience is the name of the game here, specifically by empowering a dependent crate to do 2 things:
-
Measuring the wall-clock time of any expression in nanosecond[1] resolution:
[] = "0.9"
extern crate tempus_fugit; use File; use Read; use Measurement;
The
measure!
macro returns a tuple containing the result of executing an expression (in this case a block), as well as aMeasurement
which indicates how long the expression took to execute. -
Displaying a
Measurement
in a human-readable fashion. There is aDisplay
impl forMeasurement
, so this is as easy as formatting a value with e.g.format!("{}", measurement)
.
The Measurement
type also has impls for Ord
and Eq
, which makes
comparison and sorting easy.
In addition, there is opt-in support for de/serialization through Serde.
This is activated by using the follwing in your crate's Cargo.toml
:
[]
= { = "0.9", = ["enable_serde"] }
[1] While the accounting is in nanosecond resolution, the actual resolution may be limited to courser granularity by the operating system.
Documentation
The API docs are located here.