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});