#measure-time #time #measure #metrics #performance

macro elapsed-time

This crate help you to measure time taken by a function or a block of code for print debugging purpose. It output in stdout (using println) the elapsed time.

2 releases

0.1.1 Nov 21, 2023
0.1.0 Feb 1, 2022

#509 in Debugging

Download history 5/week @ 2023-12-26 1/week @ 2024-02-13 15/week @ 2024-02-20 19/week @ 2024-02-27 14/week @ 2024-03-05 1/week @ 2024-03-12 15/week @ 2024-03-26 48/week @ 2024-04-02

64 downloads per month

MIT license

6KB
62 lines

crate

This crate help you to measure time taken by a function or a block of code for "print" debugging purpose. It output in stdout (using println) the elapsed time.

elapsed-time = "0.1"

usage

#[macro_use]
extern crate elapsed_time;

fn main() {
  // measure time taken by a block
  #[elapsed_time::elapsed_block(block_name_1)]
  {
    // some piece of code in a block
  }
  my_func();
}

// measure time taken by a function
#[elapsed_time::elapsed]
fn my_func() -> String { }

Produce following logs:

block_name_1 tooks 793.515574ms
my_func tooks 28.855µs

Dependencies

~1.5MB
~34K SLoC