#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

#22 in Date and time

Download history 1461/week @ 2019-12-17 451/week @ 2019-12-24 1277/week @ 2019-12-31 2453/week @ 2020-01-07 2950/week @ 2020-01-14 2003/week @ 2020-01-21 1546/week @ 2020-01-28 1912/week @ 2020-02-04 1361/week @ 2020-02-11 1994/week @ 2020-02-18 2920/week @ 2020-02-25 2947/week @ 2020-03-03 4192/week @ 2020-03-10 4543/week @ 2020-03-17 3544/week @ 2020-03-24 2023/week @ 2020-03-31

7,233 downloads per month
Used in 16 crates (5 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

~32KB