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!(..)
Simply add a corresponding entry to your Cargo.toml
dependency list:
toml,ignore
[dependencies]
measure_time = "0.6"
And add this to your crate root (e.g. lib.rs/main.rs):
```rust,ignore
extern crate measure_time; ```
```rust
extern crate measuretime; fn main() { infotime!("measure function"); { debugtime!("{:?}", "measuring block"); let mut sum = 0; for el in 0..50000 { sum+=el; } println!("{:?}", sum); } tracetime!("{:?}", "trace"); printtime!("print"); errortime!(target: "measure_time", "custom target"); } ```
Objects to measure time are only created when the log level is enabled, else None
will be created
Add error and warn levels
Change time formatting for improved readability
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 measuretime target (e.g. RUSTLOG=measuretime=debug). This is now fixed. Added a small example (https://github.com/PSeitz/rustmeasuretime/tree/master/measuretime_example).