Shortcuts

Source code for ding.utils.time_helper_base

[docs]class TimeWrapper(object): """ Overview: Abstract class method that defines ``TimeWrapper`` class Interfaces: ``wrapper``, ``start_time``, ``end_time`` """
[docs] @classmethod def wrapper(cls, fn): """ Overview: Classmethod wrapper, wrap a function and automatically return its running time Arguments: - fn (:obj:`function`): The function to be wrap and timed """ def time_func(*args, **kwargs): cls.start_time() ret = fn(*args, **kwargs) t = cls.end_time() return ret, t return time_func
[docs] @classmethod def start_time(cls): """ Overview: Abstract classmethod, start timing """ raise NotImplementedError
[docs] @classmethod def end_time(cls): """ Overview: Abstract classmethod, stop timing """ raise NotImplementedError