#measure #time #elapsed #wall #scope

measure_time

Provices macros to measure the time until end of scope

12 unstable releases (3 breaking)

0.6.0 Jun 24, 2018
0.5.0 May 9, 2018
0.4.2 Apr 16, 2018
0.4.1 Feb 20, 2018
0.1.3 Jun 2, 2017

#5 in Profiling

Download history 55/week @ 2018-05-27 83/week @ 2018-06-03 58/week @ 2018-06-10 157/week @ 2018-06-17 97/week @ 2018-06-24 215/week @ 2018-07-01 45/week @ 2018-07-08 43/week @ 2018-07-15 46/week @ 2018-07-22 61/week @ 2018-07-29 227/week @ 2018-08-05 79/week @ 2018-08-12 27/week @ 2018-08-19

304 downloads per month

Unlicense

9KB
111 lines

measure_time

The crate provides macros, which measure the time until end of scope.

This is done by creating an object, which measures the time. The time is printed when the object is dropped.

The logging behaviour is the same as other log macros like info!(..)

Installation

Simply add a corresponding entry to your Cargo.toml dependency list:

[dependencies]
measure_time = "0.6"

And add this to your crate root (e.g. lib.rs/main.rs):

#[macro_use]
extern crate measure_time;

Examples

#[macro_use]
extern crate measure_time;
fn main() {
    info_time!("measure function");
    {
        debug_time!("{:?}", "measuring block");
        let mut sum = 0;
        for el in 0..50000 {
            sum+=el;
        }
        println!("{:?}", sum);
    }
    trace_time!("{:?}", "trace");
    print_time!("print");
    error_time!(target: "measure_time", "custom target");
}

Changelog

Version 0.4

Objects to measure time are only created when the log level is enabled, else None will be created

Version 0.4.2

Add error and warn levels

Version 0.5.0

Change time formatting for improved readability

Version 0.6.0

Behaviour is now the same as other log macros (eg. info!). Reexporting log crate macros via pub use. Previously all tracing was made to the measure_time target (e.g. RUST_LOG=measure_time=debug). This is now fixed. Added a small example (https://github.com/PSeitz/rust_measure_time/tree/master/measure_time_example).

Dependencies

~59KB