what.models.detection.utils.time_utils API documentation

# what.models.detection.utils.time_utils

View Source

     1import timeit
     2
     3
     4class Timer:
     5    def __init__(self):
     6        self.clock = {}
     7
     8    def start(self, key="default"):
     9        self.clock[key] = timeit.default_timer()
    10
    11    def end(self, key="default"):
    12        if key not in self.clock:
    13            raise Exception(f"{key} is not in the clock.")
    14        interval = timeit.default_timer() - self.clock[key]
    15        del self.clock[key]
    16        return interval

class Timer: View Source

     5class Timer:
     6    def __init__(self):
     7        self.clock = {}
     8
     9    def start(self, key="default"):
    10        self.clock[key] = timeit.default_timer()
    11
    12    def end(self, key="default"):
    13        if key not in self.clock:
    14            raise Exception(f"{key} is not in the clock.")
    15        interval = timeit.default_timer() - self.clock[key]
    16        del self.clock[key]
    17        return interval

def start(self, key='default'): View Source

     9    def start(self, key="default"):
    10        self.clock[key] = timeit.default_timer()

def end(self, key='default'): View Source

    12    def end(self, key="default"):
    13        if key not in self.clock:
    14            raise Exception(f"{key} is not in the clock.")
    15        interval = timeit.default_timer() - self.clock[key]
    16        del self.clock[key]
    17        return interval