#timer #clock #chrono #measure #long #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

#126 in Profiling

Download history 133/week @ 2023-11-20 115/week @ 2023-11-27 43/week @ 2023-12-04 4/week @ 2023-12-18 120/week @ 2024-01-08 45/week @ 2024-01-15 47/week @ 2024-01-22 85/week @ 2024-01-29 87/week @ 2024-02-05 52/week @ 2024-02-12 141/week @ 2024-02-19 124/week @ 2024-02-26 224/week @ 2024-03-04

545 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–1MB
~20K SLoC