#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

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

#14 in #execution-time

Download history 336/week @ 2024-10-28 22/week @ 2024-11-04 144/week @ 2024-11-18

502 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