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

macro time-graph-macros

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

2 unstable releases

0.3.0 Feb 28, 2023
0.1.0 Mar 5, 2021

#88 in #instrument

Download history 612/week @ 2023-12-06 240/week @ 2023-12-13 252/week @ 2023-12-20 13/week @ 2023-12-27 271/week @ 2024-01-03 279/week @ 2024-01-10 201/week @ 2024-01-17 481/week @ 2024-01-24 1021/week @ 2024-01-31 1207/week @ 2024-02-07 1620/week @ 2024-02-14 1277/week @ 2024-02-21 996/week @ 2024-02-28 645/week @ 2024-03-06 894/week @ 2024-03-13 570/week @ 2024-03-20

3,278 downloads per month
Used in time-graph

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

~1.5MB
~33K SLoC