1 unstable release
Uses old Rust 2015
0.1.0 | Feb 13, 2018 |
---|
#40 in #dead
5KB
Tid
A dead simple timing wrapper for rough performance measurements.
See the docs for the docs.
lib.rs
:
Maybe the simplest time taking crate there is.
The timed!
macro prints the labels as {:<26}
(left aligned, 26 char length). The only
reason 26
is chosen is because my longest label happend to be around 26 chars long.
The timings are printed as floating points in microseconds, for much of the same reasons.
The exact print format is hardcoded as:
println!("[timed] {:<26} {:9.4}ms", label, (t1 - t0) as f64 / 1_000_000.0);
Examples
The crate has a macro timed!
which is used for timing a block:
timed!("pushing some stuff",
let mut v = Vec::new();
for i in 0..100 {
v.push(i);
}; // note the `;` here
);
let q = v; // `v` is still reachable out here.
If you have multiple consecutive blocks, you can use Timer
instead.
let mut t = Timer::new();
f();
t.mark("Doing f");
g();
t.mark("G is executed");
h();
t.mark("Done with H");
t.present();
Dependencies
~0.6–1MB
~15K SLoC