exec_time 0.1.5

Print execution time of a function
Documentation

exec_time

Attribute macro for printing function execution time.

License: MIT Crates.io Build Status

Install

[dependencies]
exec_time = "0.1.4"

MSRV: Rust 1.88.

Example

use exec_time::exec_time;

#[exec_time]
fn login() {
    std::thread::sleep(std::time::Duration::from_millis(100));
}

fn main() {
    login();
}
Time login: 102 ms

Options

  • print = "always": print in all builds. Default.
  • print = "debug": print only in debug builds.
  • print = "never": disable printing.
  • prefix = "...": prepend a label before the function name.
  • suffix = "...": append a label after the function name.

Custom Label

use exec_time::exec_time;

#[exec_time(prefix = "user/lib", suffix = "route")]
fn login() {
    std::thread::sleep(std::time::Duration::from_millis(100));
}
Time user/lib::login::route: 102 ms