def precision_sleep(t=0.02, min_time=0.017):
    """
    sleep for t seconds.
    """
    from time import time, sleep, perf_counter
    import platform
    min_time
    time_start = perf_counter()
    if platform.system() == 'Linux':
        sleep(t)
    elif t > min_time:
        sleep(t - min_time)
        time_left = t - (perf_counter() - time_start)
        time_while_start = perf_counter()
        while perf_counter() - time_while_start <= time_left:
            pass
    else:
        time_left = t - (perf_counter() - time_start)
        time_while_start = perf_counter()
        while perf_counter() - time_while_start <= time_left:
            pass
