#execution #execution-time #logging #duration #timing #blocks #time-execution

logtime

A Rust library for timing and optionally logging the execution of code blocks

4 releases

0.1.3 Nov 21, 2024
0.1.2 Oct 31, 2024
0.1.1 Oct 30, 2024
0.1.0 Oct 30, 2024

#15 in #execution-time

Download history 271/week @ 2024-10-25 78/week @ 2024-11-01 9/week @ 2024-11-08 111/week @ 2024-11-15 38/week @ 2024-11-22 4/week @ 2024-11-29

168 downloads per month

MIT license

4KB

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

No runtime deps