2 releases (1 stable)

Uses old Rust 2015

1.0.0 Oct 27, 2019
0.1.0 Aug 23, 2018

#108 in Profiling

Download history 55416/week @ 2023-12-17 17673/week @ 2023-12-24 39907/week @ 2023-12-31 57387/week @ 2024-01-07 68317/week @ 2024-01-14 64633/week @ 2024-01-21 59778/week @ 2024-01-28 62743/week @ 2024-02-04 66351/week @ 2024-02-11 74232/week @ 2024-02-18 81431/week @ 2024-02-25 77435/week @ 2024-03-03 65293/week @ 2024-03-10 71512/week @ 2024-03-17 76284/week @ 2024-03-24 98598/week @ 2024-03-31

314,028 downloads per month
Used in 78 crates (43 directly)

MIT/Apache

15KB
169 lines

CPU Time Measurement Library

Documentation | Github | Crate

A simple and idiomatic interface for measurement CPU time:


let start = ProcessTime::now();
# .. do something ..
let cpu_time: Duration = start.elapsed();
println!(" {:?}");

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

CPU Time Measurement Library

Documentation | Github | Crate

Example


use std::time::Duration;
use cpu_time::ProcessTime;

// Manually handle errors
let start = ProcessTime::try_now().expect("Getting process time failed");
// .. do something ..
let cpu_time: Duration = start.try_elapsed().expect("Getting process time failed");;
println!(" {:?}", cpu_time);

// Panic in case of an error
let start = ProcessTime::now();
// .. do something ..
let cpu_time: Duration = start.elapsed();
println!(" {:?}", cpu_time);

Dependencies

~215KB