Expand description
This crate allows you to measure how long it takes for a program to execute in different
clocks. It ports the functions of the boost-chrono
and boost-timer libraries.
The following clocks and their corresponding timers are implemented.
SystemClock,SystemTimerSteadyClock,SteadyTimerif supported by the system.HighResolutionClock,HighResolutionTimerProcessRealCPUClock,ProcessRealCPUTimerProcessUserCPUClock,ProcessUserCPUTimerProcessSystemCPUClock,ProcessSystemCPUTimerProcessCPUClock,ProcessCPUTimerThreadClock,ThreadTimer
See crate::clock to read more about their differences.
§Usage
Add this to your Cargo.toml:
[dependencies]
howlong = "0.1"§Examples
let timer = howlong::HighResolutionTimer::new();
// do some computations
println!("{:?} have passed.", timer.elapsed());
let timer = howlong::ProcessCPUTimer::new();
// do other computations
println!("{}", timer.elapsed()); // 5.71s wall, 5.70s user + 0ns system = 5.70s CPU (99.8%)Re-exports§
Modules§
- clock
- Measure the current time using different clocks.
- timer
- Measure how long a program takes to execute.
Structs§
- Duration
- A
Durationtype to represent a span of time, typically used for system timeouts. - Process
Duration - Like
Durationbut captures real, user-CPU, and system-CPU process times. - Process
Time Point - Like
TimePointbut captures real, user-CPU, and system-CPU process times. - Time
Point - A point in time.
Enums§
- Error
- Error type for this crate.
Traits§
- Clock
- A trait to represent a clock.
Type Aliases§
- Result
- Alias to
core::result::Result<T, howlong::Error>