| Crates.io | howlong |
| lib.rs | howlong |
| version | 0.1.7 |
| created_at | 2019-12-05 13:15:55.503058+00 |
| updated_at | 2021-04-05 12:26:38.425378+00 |
| 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, SystemTimerSteadyClock, SteadyTimer if supported by the system.HighResolutionClock, HighResolutionTimerProcessRealCPUClock, ProcessRealCPUTimerProcessUserCPUClock, ProcessUserCPUTimerProcessSystemCPUClock, ProcessSystemCPUTimerProcessCPUClock, ProcessCPUTimerThreadClock, ThreadTimerAdd 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%)