| Crates.io | ttimer |
| lib.rs | ttimer |
| version | 0.1.3 |
| created_at | 2023-12-13 04:23:46.153095+00 |
| updated_at | 2023-12-15 22:08:24.255203+00 |
| description | A tiny crate used for timing individual functions |
| homepage | |
| repository | https://github.com/sfrembling/timer |
| max_upload_size | |
| id | 1067662 |
| size | 6,265 |
A simple and tiny timing crate.
// time a function's execution
let result = timer!(some_function);
println!("Took {} ns", result.time.as_nanos());
// time execution and use output
fn some_function(a: i32, b: &str) -> Option<usize> {
/* code */
}
let result = timer!(some_function, 12, "Some input string");
if let Some(value) = result.result {
println!("Took {} ns to find {}", result.time.as_nanos(), value);
} else {
println!("Took {} ns", result.time.as_nanos());
}