#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 2573/week @ 2021-02-26 2161/week @ 2021-03-05 2217/week @ 2021-03-12 1696/week @ 2021-03-19 1451/week @ 2021-03-26 1481/week @ 2021-04-02 2118/week @ 2021-04-09 1925/week @ 2021-04-16 1606/week @ 2021-04-23 1551/week @ 2021-04-30 1895/week @ 2021-05-07 1881/week @ 2021-05-14 1573/week @ 2021-05-21 1471/week @ 2021-05-28 1406/week @ 2021-06-04 1155/week @ 2021-06-11

7,659 downloads per month
Used in 25 crates (14 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

~34KB