def stop(self): elapsed = python_timer() - self._start self._start = None if self._mode == "serial": return self._comm.allreduce(elapsed, op=MAX) elif self._mode == "parallel": return self._comm.allreduce(elapsed, op=SUM) else: raise ValueError("Invalid mode for timer")
def __float__(self): time_taken = python_timer() - self.start return round(time_taken, self.round_to) if self.round_to else time_taken
def __init__(self, round_to=None, **kwargs): self.start = python_timer() self.round_to = round_to
def start(self): self._start = python_timer()