monkey/envs/monkey_zoo/blackbox/utils/test_timer.py

18 lines
407 B
Python
Raw Normal View History

from time import time
class TestTimer(object):
def __init__(self, timeout):
self.timeout_time = TestTimer.get_timeout_time(timeout)
self.start_time = time()
2019-10-01 15:42:51 +08:00
def is_timed_out(self):
return time() > self.timeout_time
def get_time_taken(self):
return time() - self.start_time
@staticmethod
def get_timeout_time(timeout):
return time() + timeout