Crates.io | howlong |
lib.rs | howlong |
version | 0.1.7 |
source | src |
created_at | 2019-12-05 13:15:55.503058 |
updated_at | 2021-04-05 12:26:38.425378 |
description | Measure how long it takes for a program to execute in different clocks |
homepage | |
repository | https://github.com/xu-cheng/howlong |
max_upload_size | |
id | 186655 |
size | 57,168 |
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
, SystemTimer
SteadyClock
, SteadyTimer
if supported by the system.HighResolutionClock
, HighResolutionTimer
ProcessRealCPUClock
, ProcessRealCPUTimer
ProcessUserCPUClock
, ProcessUserCPUTimer
ProcessSystemCPUClock
, ProcessSystemCPUTimer
ProcessCPUClock
, ProcessCPUTimer
ThreadClock
, ThreadTimer
Add this to your Cargo.toml
:
[dependencies]
howlong = "0.1"
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%)