macro_rules! time {
    ($e:expr) => { ... };
    ($e:expr,) => { ... };
    ($($e:expr),+ $(,)?) => { ... };
}
Expand description

Print out the time it took to execute a given expression in seconds.

Much like Rust standard library dbg! macro, but prints the time it takes to run what is passed.

Like dbg! macro, this also supports more than one expression, returning a tuple with the evaluated expressions

Note: requires Rust unstable feature duration_float, so it lives on crate feature nightly.

Example

use sugars::{time, dur};
let d = dur!(10 sec);
// Sleeps for 10 seconds
time!(std::thread::sleep(d)); // Should print 10.000 at least

With multiple expr:

Assume some_comp() and another_comp() as two function that compute something that takes some time.

use sugars::time;
let (a, b) = time!(some_comp(), another_comp());