Crate macrotime

Crate macrotime 

Source
Expand description

§MacroTime

§time!

MacroTime is very easy to use. To time the execution of a block of code:

use macrotime::*;
let time = time!({
    // do some stuff...
});
println!("This operation took {} ms!", time.as_millis());

§dbg_time!

You can also have MacroTime print the time taken to perform a task on its own. To do this:

use macrotime::*;
dbg_time!("context...", {
    // do some stuff...
});

In this scenario, the time will printed in the most relevant unit, so no need for formatting.

Return statements within the debug macro will be propogated to the outer scope, and can be used elsewhere in the code, for minimal disruption to program flow.

let result = dbg_time!("returning 123...", {123});

Macros§

dbg_time
Prints the execution time of the provided expression along with a relevant title/message. Returns the result of the expression.
time
Returns a Duration of the execution time of the provided expression.