elapsed-time

Crates.ioelapsed-time
lib.rselapsed-time
version0.2.0
created_at2022-02-01 15:58:25.661982+00
updated_at2025-09-28 19:22:37.465953+00
descriptionThis 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.
homepage
repositoryhttps://github.com/nmeylan/elapsed-time
max_upload_size
id525239
size16,163
Nicolas Meylan (nmeylan)

documentation

README

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

Features

  • tracing: use tracing crate for logging instead of println
  • log: use log crate for logging instead of println
Commit count: 8

cargo fmt