def _timeitlike_time_format(time_seconds, precision=3):
    """Shamelessly adapted formatting from timeit.py

    Parameters
    ----------
    time_seconds : float
        The time in seconds
    precision : int
        The precision of the output. All digits.

    Returns
    -------
    str
        A timeit-like format (with usec, msec, sec).
    """
    usec = time_seconds * 1e6
    if usec < 1000:
        return "%.*g usec" % (precision, usec)
    else:
        msec = usec / 1000
        if msec < 1000:
            return "%.*g msec" % (precision, msec)
        else:
            sec = msec / 1000
            return "%.*g sec" % (precision, sec)