Expand description
§Hemera
A lightweight attribute macro for measuring function execution time with divine precision.
§Usage
use hemera::measure_time;
#[measure_time]
fn calculate_fibonacci(n: u32) -> u32 {
if n <= 1 {
n
} else {
calculate_fibonacci(n - 1) + calculate_fibonacci(n - 2)
}
}
#[measure_time(name = "CustomTimer", level = "debug")]
fn slow_function() {
std::thread::sleep(std::time::Duration::from_millis(100));
}
#[measure_time(threshold = "50ms")]
fn maybe_slow(n: u32) {
// Only logs if execution takes more than 50ms
std::thread::sleep(std::time::Duration::from_millis(n as u64));
}§Async Support
use hemera::measure_time;
#[measure_time]
async fn fetch_data() -> String {
// Async function timing
"data".to_string()
}§Tracing Integration
Enable the tracing feature for integration with the tracing ecosystem:
[dependencies]
hemera = { version = "0.1", features = ["tracing"] }Attribute Macros§
- measure_
time - Attribute macro for measuring function execution time