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

#85 in Date and time

Download history 96721/week @ 2024-06-19 115581/week @ 2024-06-26 107787/week @ 2024-07-03 107618/week @ 2024-07-10 123457/week @ 2024-07-17 117405/week @ 2024-07-24 106763/week @ 2024-07-31 137679/week @ 2024-08-07 148285/week @ 2024-08-14 140403/week @ 2024-08-21 135441/week @ 2024-08-28 165624/week @ 2024-09-04 166093/week @ 2024-09-11 162593/week @ 2024-09-18 171945/week @ 2024-09-25 148126/week @ 2024-10-02

681,422 downloads per month
Used in 89 crates (48 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