3 releases

Uses new Rust 2024

new 0.1.2 Apr 2, 2025
0.1.1 Mar 30, 2025
0.1.0 Mar 30, 2025

#384 in Debugging

Download history 81/week @ 2025-03-24 268/week @ 2025-03-31

349 downloads per month

MIT license

8KB
86 lines

timetrap

Static Badge Rust Crates.io Version Static Badge

Description

timetrap library is intended to wrap your code and measure the time of its execution.

Install it as:

cargo install timetrap

Time

Example of use:

use timetrap::*;

trap!("section A", {
     let a = 0;
     ...
});

which results in:

section A took 14.834µs

Memeory

Also with help of sysinfo you can measure memory usage in the same manner.

Example of use:

use timetrap::*;

trap_mem!("make_plot()", MemUnits.Kb, {
     let a = 0;
     ...
});

which results in:

make_plot() took 928.328083ms
make_plot() consumed memory: 560.00Kb
make_plot() consumed swap: 0.00Kb


Dependencies

~780KB
~18K SLoC