src.utils.timer module#
Lightweight timing utilities for optional performance diagnostics.
- class src.utils.timer.Timer(unit='iter', mode: Literal['pace', 'speed', 'counter', 'timer'] = 'pace')[source]#
Bases:
object- property speed#
- class src.utils.timer.AbsTimer(unit='iter', mode: Literal['pace', 'speed', 'counter', 'timer'] = 'pace')[source]#
Bases:
Timer
- class src.utils.timer.NamedTimer(unit='iter', mode: Literal['pace', 'speed', 'counter', 'timer'] = 'pace')[source]#
Bases:
TimerNamed timer for collecting per-stage timing statistics.
Useful for analyzing time distribution across phases such as data loading, forward passes, and post-processing during training or inference.
- __init__(unit='iter', mode: Literal['pace', 'speed', 'counter', 'timer'] = 'pace')[source]#
- Parameters:
unit (str) – Unit suffix for display, such as ‘iter’.
mode (str) – Display mode. - ‘pace’: time per unit, e.g. 100ms/iter - ‘speed’: units completed per second, e.g. 10iter/s
- add(name, n=1, update_time=True)[source]#
Record time spent in the stage identified by name.
- Parameters:
name (str) – Stage name.
n (int, optional) – Completed work count.
update_time (bool, optional) – Whether to reset the start time.
- property time#
- property count#