def testGetTimeTicksNow(self): v1 = system.GetTimeTicksNow() time.sleep(1e-3) v2 = system.GetTimeTicksNow() self.assertGreater(v1, 0) self.assertGreater(v2, v1 + 1e2) self.assertLess(v2, v1 + 1e5)
def __init__(self, data_pipe, deadline, resolve, reject): self.data_pipe = data_pipe self.original_deadline = deadline self.start_time = mojo_system.GetTimeTicksNow() self.resolve = resolve self.reject = reject self.buffer_size = 1024 self.data = bytearray(self.buffer_size) self.index = 0
def _ComputeCurrentDeadline(self): if self.original_deadline == mojo_system.DEADLINE_INDEFINITE: return self.original_deadline elapsed_time = mojo_system.GetTimeTicksNow() - self.start_time return max(0, self.original_deadline - elapsed_time)