Crates.io | logtime |
lib.rs | logtime |
version | 0.1.3 |
source | src |
created_at | 2024-10-30 12:21:25.646241 |
updated_at | 2024-11-21 01:25:06.430023 |
description | A Rust library for timing and optionally logging the execution of code blocks. |
homepage | |
repository | |
max_upload_size | |
id | 1428435 |
size | 3,181 |
Logtime is a Rust library for measuring and optionally logging the execution time of code.
Add logtime to your Cargo.toml
:
[dependencies]
logtime = "0.1.0"
use logtime::{time_execution, log_execution_time};
fn main() {
let (_, duration) = time_execution(|| {
// code to time
std::thread::sleep(std::time::Duration::from_millis(100));
});
println!("Code block took {:?}", duration);
log_execution_time("sleep_200ms", || {
std::thread::sleep(std::time::Duration::from_millis(200));
});
}
This project is licensed under the MIT License
bensatlantik