Profiler#
- class lumopt2.utils.profiler.Profiler(enabled: bool = True)#
Aggregate wall-clock time per named category.
Categories are tracked hierarchically via a context-stack: nesting one
measure()inside another produces a slash-joined full path such as"compute_gradient/dEps_phase/perturbation_loop". Each unique full path is its own bucket and gets its own count / total / min / max statistics.The profiler is enabled by default and can be globally toggled with
enable()/disable(). When disabled,measure()is a no-op with sub-microsecond overhead.- Parameters:
Methods
Disable timing measurements; subsequent
measurecalls are no-ops.Enable timing measurements.
Profiler.format_summary(*[, min_total_seconds])Return a tree-formatted string summarizing recorded categories.
Return a snapshot of the current statistics.
Profiler.log_summary([level, ...])Log the formatted summary to a logger.
Profiler.measure(name)Time the wrapped block and accumulate it under
name.Clear all accumulated statistics and the active context stack.