#cpu #time #cpu-time

cpu-time

Small crate that provides CPU time measurement

2 releases (1 stable)

1.0.0 Oct 27, 2019
0.1.0 Aug 23, 2018

#13 in Date and time

Download history 1046/week @ 2019-07-14 765/week @ 2019-07-21 774/week @ 2019-07-28 1095/week @ 2019-08-04 1452/week @ 2019-08-11 777/week @ 2019-08-18 805/week @ 2019-08-25 818/week @ 2019-09-01 1125/week @ 2019-09-08 1153/week @ 2019-09-15 321/week @ 2019-09-22 801/week @ 2019-09-29 637/week @ 2019-10-06 960/week @ 2019-10-13 1808/week @ 2019-10-20

4,149 downloads per month
Used in 8 crates (3 directly)

MIT/Apache

14KB
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

~31KB