https://github.com/xu-cheng/howlong
:watch: Measure how long it takes for a program to execute in different clocks
https://github.com/xu-cheng/howlong
profiling-library rust timer-clock
Last synced: about 1 month ago
JSON representation
:watch: Measure how long it takes for a program to execute in different clocks
- Host: GitHub
- URL: https://github.com/xu-cheng/howlong
- Owner: xu-cheng
- License: apache-2.0
- Created: 2019-12-04T14:47:19.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-01T05:18:38.000Z (over 3 years ago)
- Last Synced: 2024-10-12T21:09:10.671Z (7 months ago)
- Topics: profiling-library, rust, timer-clock
- Language: Rust
- Homepage: https://docs.rs/howlong
- Size: 69.3 KB
- Stars: 11
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# howlong
[](https://github.com/xu-cheng/howlong/actions)
[](https://crates.io/crates/howlong)
[](https://docs.rs/howlong)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`](https://boost.org/libs/chrono) and [`boost-timer`](https://boost.org/libs/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
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
howlong = "0.1"
```## Examples
```rust
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.