TimeRun
Structured timing for Python. One small library, no dependencies — wall and CPU time, ready for your logs, metrics, or tracing.
About¶
You need to measure execution time of Python code in a way that’s trustworthy (wall + CPU, not ad-hoc timers), observable (send to logging, OpenTelemetry, or any pipeline), and low-friction (no new dependencies, works in scripts and production). TimeRun does exactly that.
- Zero dependencies — Standard library only; safe for libraries and constrained environments.
- Wall + CPU time — Distinguish real elapsed time from CPU burn (I/O vs CPU-bound).
- Observability-ready —
on_start/on_endcallbacks and metadata to plug into logging, OpenTelemetry, or any metrics pipeline.
Read the full story for positioning →
Quick start¶
Install from PyPI¶
Measure code block¶
Measure function calls¶
Use measurement result¶
>>> m.wall_time.timedelta
datetime.timedelta(microseconds=11)
>>> m.cpu_time.timedelta
datetime.timedelta(microseconds=8)
Read the reference for API details →