#measure #time #elapsed #wall #humantime

measure_time

Provices macros to measure the time until end of scope

14 unstable releases (5 breaking)

Uses old Rust 2015

0.8.0 Nov 4, 2021
0.7.0 Jun 30, 2021
0.6.0 Jun 24, 2018
0.4.1 Feb 20, 2018
0.1.3 Jun 2, 2017

#23 in Profiling

Download history 456/week @ 2021-08-11 486/week @ 2021-08-18 789/week @ 2021-08-25 719/week @ 2021-09-01 1390/week @ 2021-09-08 1254/week @ 2021-09-15 1077/week @ 2021-09-22 1174/week @ 2021-09-29 1163/week @ 2021-10-06 969/week @ 2021-10-13 1376/week @ 2021-10-20 1250/week @ 2021-10-27 1269/week @ 2021-11-03 1689/week @ 2021-11-10 1857/week @ 2021-11-17 1530/week @ 2021-11-24

6,584 downloads per month
Used in 12 crates (3 directly)

Unlicense

14KB
290 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.7"

Examples

use measure_time::{info_time, debug_time, trace_time, error_time, print_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).

Version 0.7.0

Support 2018 imports, with improved macro import hygiene.

Dependencies

~80KB