nip.timing.timeables.register_timeable#
- nip.timing.timeables.register_timeable(_timeable: type[Timeable] | Callable | None = None, *, name: str | None = None) Callable | type[Timeable] [source]#
Register a timeable.
If a callable is given, a subclass of Timeable is created with the callable as the run method.
- Parameters:
- Returns:
Timeable – The timeable that was registered. If a callable was given, the subclass of Timeable that was created is returned.
Examples
Register a subclass of Timeable: >>> @register_timeable(name=”my_timeable”) … class MyTimeable(Timeable): … def __init__(self): … pass … def run(self, profiler): … pass
Register a callable: >>> @register_timeable … def my_timeable(profiler): … pass