time-graph provides always-on profiling for your code, allowing to
record the execution time of functions, spans inside these functions and the
full call graph of spans and functions at run-time.
There are two main concepts in this crate:
CallSite identify a single
call site in the source, usually a full function. One can then create a
Span from any callsite, representing a single execution of the code.
When executed, the
Span will its elapsed time, and store it in the
global call graph.
By default, no data is collected until you call
to start collecting timing data. Once you are done running your code, you
can extract collected data with
get_full_graph, and possibly clear all
collected data using
When data collection is disabled, this crate adds an overheard around 10 ns when calling a function or entering a span. With data collection enabled, this crate adds an overhead around 100 ns when calling a function or entering a span.
This makes this crate only useful for gathering profiling data on function/spans taking at least 1 µs to execute.
This crate has two cargo features:
- json: enables json output format for the full call graph
- table: enables pretty-printing the full call graph to a table using term-table
Create a new
Run a block of code inside a new span
Full call graph including execution time and number of calls between functions/spans.
Clear the global call graph from all data
Enable/disable data collection
Get a copy of the call graph as currently known
Execute the given function on all call sites we know about.