profiling
sorix.utils.profiling ¶
Lightweight profiling utilities for Sorix.
Provides:
- profile_func decorator that records execution time using cProfile and
optionally captures peak memory usage via memory_profiler.
- profiler context manager for ad‑hoc profiling blocks.
The results are written to tests/benchmark/profile_report.txt for easy CI
inspection.
profile_func ¶
Decorator that profiles func.
It records:
- Real‑world wall‑clock time.
- cProfile CPU statistics (total time, calls, per‑call time).
- Peak memory usage if memory_profiler is available.
The formatted report is appended to tests/benchmark/profile_report.txt.
Source code in sorix/utils/profiling.py
profiler ¶
Context manager for ad‑hoc profiling.
Usage::
with profiler("my_section"):
heavy_computation()