#time-graph #macro-attributes

macro time-graph-macros

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

4 releases

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

#565 in Profiling

Download history 104/week @ 2025-10-22 150/week @ 2025-10-29 224/week @ 2025-11-05 327/week @ 2025-11-12 187/week @ 2025-11-19 129/week @ 2025-11-26 597/week @ 2025-12-03 229/week @ 2025-12-10 81/week @ 2025-12-17 41/week @ 2025-12-24 296/week @ 2025-12-31 80/week @ 2026-01-07 82/week @ 2026-01-14 87/week @ 2026-01-21 336/week @ 2026-01-28 215/week @ 2026-02-04

727 downloads per month
Used in 9 crates (via time-graph)

Apache-2.0/MIT

7KB
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

~115–490KB
~12K SLoC