| Crates.io | timer_macro |
| lib.rs | timer_macro |
| version | 0.1.4 |
| created_at | 2024-12-31 10:45:07.004641+00 |
| updated_at | 2024-12-31 11:45:59.944698+00 |
| description | A macro to print time taken to execute a function |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1499898 |
| size | 5,707 |
cargo add timer_macro
#[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(())
}