#timer #clock #chrono #measure #different #execute #how

howlong

Measure how long it takes for a program to execute in different clocks

8 releases

0.1.7 Apr 5, 2021
0.1.6 Oct 20, 2020
0.1.5 Jun 20, 2020
0.1.4 Apr 19, 2020
0.1.2 Dec 6, 2019

#198 in Profiling

Download history 55/week @ 2024-07-26 18/week @ 2024-08-02 27/week @ 2024-08-09 11/week @ 2024-08-16 44/week @ 2024-08-23 112/week @ 2024-08-30 53/week @ 2024-09-06 178/week @ 2024-09-13 103/week @ 2024-09-20 115/week @ 2024-09-27 21/week @ 2024-10-04 17/week @ 2024-10-11 18/week @ 2024-10-18 40/week @ 2024-10-25 58/week @ 2024-11-01 38/week @ 2024-11-08

158 downloads per month
Used in benchlib-rs

MIT/Apache

37KB
701 lines

howlong

Build Status Latest Version Rust Documentation

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

Documentation

https://docs.rs/howlong

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%)

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.3–1.4MB
~27K SLoC