Crates.io | measure_time |
lib.rs | measure_time |
version | 0.9.0 |
source | src |
created_at | 2017-06-02 12:48:38.495407 |
updated_at | 2024-12-09 13:46:37.079615 |
description | Provices macros to measure the time until end of scope. |
homepage | https://github.com/PSeitz/rust_measure_time |
repository | https://github.com/PSeitz/rust_measure_time |
max_upload_size | |
id | 17321 |
size | 15,338 |
The crate provides macros, which measure the time until end of scope and print the elapsed time in a human readable format.
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:
[dependencies]
measure_time = "0.8"
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");
}
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 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).
Support 2018 imports, with improved macro import hygiene.
Fix human readable time, see https://github.com/PSeitz/rust_measure_time/commit/bd829342aaed87db84f49ee6f7f46749b8c8e2ca for details.
Use wasm-compatible Instant https://github.com/PSeitz/rust_measure_time/issues/3
Use std::Instant