5 releases
0.1.4 | Dec 31, 2024 |
---|---|
0.1.3 | Dec 31, 2024 |
0.1.2 | Dec 31, 2024 |
0.1.1 | Dec 31, 2024 |
0.1.0 | Dec 31, 2024 |
#380 in Procedural macros
394 downloads per month
4KB
A crate to print time taken to execute a function
Features
- Handle any number and type of parameter(s)
- Handle asynchronous function(s)
- Handle alternative logging like file or rsyslog
Install
cargo add timer_macro
Usage
#[timer_macro::timer]
pub fn example_timer(x: usize, y: usize) -> Result<usize, Box<dyn std::error::Error>> {
std::thread::sleep(std::time::Duration::from_millis(500));
Ok(x + y)
}
#[timer_macro::timer]
pub async fn example_timer_async(pause: u64) -> Result<(), Box<dyn std::error::Error>> {
std::thread::sleep(std::time::Duration::from_millis(pause));
Ok(())
}
Dependencies
~215–650KB
~16K SLoC