def to_units(td):
    """Pretty prints the time in the right units.

    Parameters
    ----------
    td : float
        The time to be printed.
    
    Returns
    -------
    str
        The printed time
    """

    if td > 1e-6:
        return "%.4f us" % (td * 1e6)
    if td > 1e-9:
        return "%.4f ns" % (td * 1e9)
    if td > 1e-12:
        return "%.4f ps" % (td * 1e12)
    
    return "%.4f fs" % (td * 1e15)