2 releases (1 stable)

Uses old Rust 2015

1.0.0 Oct 27, 2019
0.1.0 Aug 23, 2018

#117 in Profiling

Download history 79364/week @ 2024-02-27 73673/week @ 2024-03-05 65357/week @ 2024-03-12 75647/week @ 2024-03-19 73761/week @ 2024-03-26 103975/week @ 2024-04-02 99245/week @ 2024-04-09 96673/week @ 2024-04-16 95333/week @ 2024-04-23 85237/week @ 2024-04-30 85348/week @ 2024-05-07 105053/week @ 2024-05-14 106700/week @ 2024-05-21 115960/week @ 2024-05-28 119507/week @ 2024-06-04 94080/week @ 2024-06-11

452,544 downloads per month
Used in 83 crates (48 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