2 releases (1 stable)

Uses old Rust 2015

1.0.0 Oct 27, 2019
0.1.0 Aug 23, 2018

#148 in Profiling

Download history 145164/week @ 2024-08-09 151245/week @ 2024-08-16 141596/week @ 2024-08-23 138462/week @ 2024-08-30 166274/week @ 2024-09-06 153527/week @ 2024-09-13 187367/week @ 2024-09-20 162787/week @ 2024-09-27 211445/week @ 2024-10-04 182204/week @ 2024-10-11 203890/week @ 2024-10-18 229248/week @ 2024-10-25 201190/week @ 2024-11-01 214571/week @ 2024-11-08 187434/week @ 2024-11-15 129159/week @ 2024-11-22

776,112 downloads per month
Used in 91 crates (50 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

~220KB