macro_rules! log_time {
($($expr:tt)*) => { ... };
}Expand description
Times the execution of code and automatically logs the duration to stderr.
This is a convenience macro that combines format_time! with automatic logging.
It times the execution of code and prints the timing information to stderr,
returning only the result of the executed code.
§Examples
§Single operation with message
use arbitime::log_time;
let result = log_time!("Database query" => {
// Simulate some work
42
});
// Prints: "Database query - Execution time: ..."
assert_eq!(result, 42);§Simple timing without custom message
use arbitime::log_time;
let result = log_time! {
(1..=100).sum::<u32>()
};
// Prints: "Execution time: ..."§Output
All timing information is printed to stderr using eprintln!.
§Returns
The result of the executed code (type T).