#cpu #time #cpu-time

cpu-time

Small crate that provides CPU time measurement

2 releases (1 stable)

Uses old Rust 2015

1.0.0 Oct 27, 2019
0.1.0 Aug 23, 2018

#90 in Date and time

Download history 7641/week @ 2022-12-01 7888/week @ 2022-12-08 7375/week @ 2022-12-15 4653/week @ 2022-12-22 4232/week @ 2022-12-29 8630/week @ 2023-01-05 9549/week @ 2023-01-12 10699/week @ 2023-01-19 9353/week @ 2023-01-26 11024/week @ 2023-02-02 12438/week @ 2023-02-09 13206/week @ 2023-02-16 16459/week @ 2023-02-23 14510/week @ 2023-03-02 14945/week @ 2023-03-09 17934/week @ 2023-03-16

67,021 downloads per month
Used in 43 crates (28 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

~36KB