#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

#3 in #cpu-time

Download history 54844/week @ 2023-11-03 58085/week @ 2023-11-10 56072/week @ 2023-11-17 54171/week @ 2023-11-24 82411/week @ 2023-12-01 63660/week @ 2023-12-08 56897/week @ 2023-12-15 20406/week @ 2023-12-22 34968/week @ 2023-12-29 56743/week @ 2024-01-05 64314/week @ 2024-01-12 68315/week @ 2024-01-19 59312/week @ 2024-01-26 62436/week @ 2024-02-02 64696/week @ 2024-02-09 57127/week @ 2024-02-16

254,786 downloads per month
Used in 79 crates (44 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