#instrument #attributes #macro #record #function #time-graph

macro time-graph-macros

Attribute macro to instrument functions and record their executing time with the time-graph crate

3 unstable releases

0.3.2 Sep 25, 2024
0.3.0 Feb 28, 2023
0.1.0 Mar 5, 2021

#85 in #instrument

Download history 306/week @ 2024-10-16 695/week @ 2024-10-23 1133/week @ 2024-10-30 790/week @ 2024-11-06 1218/week @ 2024-11-13 1488/week @ 2024-11-20 1695/week @ 2024-11-27 1203/week @ 2024-12-04 1509/week @ 2024-12-11 453/week @ 2024-12-18 137/week @ 2024-12-25 444/week @ 2025-01-01 612/week @ 2025-01-08 723/week @ 2025-01-15 562/week @ 2025-01-22 1648/week @ 2025-01-29

3,658 downloads per month
Used in 253 crates (160 directly)

Apache-2.0/MIT

6KB
78 lines

A procedural macro attribute for instrumenting functions with time-graph.

time-graph provides always-on profiling for your code, allowing to record the execution time of functions, spans inside these functions and the actual call graph at run-time. This crate provides the #[instrument] procedural macro attribute.

Note that this macro is also re-exported by the main time-graph crate.

Usage

First, add this to your Cargo.toml:

[dependencies]
time-graph-macros = "0.1.0"

The #[instrument] attribute can now be added to a function to automatically create a time-graph callsite, and enter the corresponding span when that function is called. For example:

use time_graph_macros::instrument;

#[instrument]
pub fn my_function(my_arg: usize) {
    // ...
}

Dependencies

~275–740KB
~18K SLoC