codeflash/code_to_optimize/sleeptime.py
2024-10-23 14:38:23 -07:00

10 lines
225 B
Python

import time
def accurate_sleepfunc(t) -> float:
"""T is in seconds"""
start_time = time.perf_counter_ns()
while True:
if (time.perf_counter_ns() - start_time) / 10e9 >= t:
break
return t