2 releases (1 stable)

Uses old Rust 2015

1.0.0 Oct 27, 2019
0.1.0 Aug 23, 2018

#123 in Profiling

Download history 201190/week @ 2024-11-01 214571/week @ 2024-11-08 187434/week @ 2024-11-15 141206/week @ 2024-11-22 104375/week @ 2024-11-29 193475/week @ 2024-12-06 181632/week @ 2024-12-13 50701/week @ 2024-12-20 61747/week @ 2024-12-27 172656/week @ 2025-01-03 202668/week @ 2025-01-10 162875/week @ 2025-01-17 179155/week @ 2025-01-24 180718/week @ 2025-01-31 185443/week @ 2025-02-07 70922/week @ 2025-02-14

648,725 downloads per month
Used in 98 crates (53 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