logtime

Crates.iologtime
lib.rslogtime
version0.1.3
sourcesrc
created_at2024-10-30 12:21:25.646241
updated_at2024-11-21 01:25:06.430023
descriptionA Rust library for timing and optionally logging the execution of code blocks.
homepage
repository
max_upload_size
id1428435
size3,181
Ben Santora (bensatlantik)

documentation

README

logtime

Logtime is a Rust library for measuring and optionally logging the execution time of code.

Usage

Add logtime to your Cargo.toml:

[dependencies]
logtime = "0.1.0"

Examples


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));
    });
}

License

This project is licensed under the MIT License

Author

bensatlantik

Commit count: 0

cargo fmt