#time #cpu #api-bindings

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

#115 in Profiling

Download history 53809/week @ 2023-11-21 66160/week @ 2023-11-28 74352/week @ 2023-12-05 60311/week @ 2023-12-12 45238/week @ 2023-12-19 17288/week @ 2023-12-26 50092/week @ 2024-01-02 56264/week @ 2024-01-09 71921/week @ 2024-01-16 63240/week @ 2024-01-23 58889/week @ 2024-01-30 66897/week @ 2024-02-06 63915/week @ 2024-02-13 79899/week @ 2024-02-20 79364/week @ 2024-02-27 61001/week @ 2024-03-05

299,720 downloads per month
Used in 76 crates (43 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