def parse_readable_time_str(time_str):
    """Parses a time string in the format N, Nus, Nms, Ns.

    Args:
      time_str: (`str`) string consisting of an integer time value optionally
        followed by 'us', 'ms', or 's' suffix. If suffix is not specified,
        value is assumed to be in microseconds. (e.g. 100us, 8ms, 5s, 100).

    Returns:
      Microseconds value.
    """

    def _parse_positive_float(value_str):
        value = float(value_str)
        if value < 0:
            raise ValueError(
                "Invalid time %s. Time value must be positive." % value_str)
        return value

    time_str = time_str.strip()
    if time_str.endswith("us"):
        return int(_parse_positive_float(time_str[:-2]))
    elif time_str.endswith("ms"):
        return int(_parse_positive_float(time_str[:-2]) * 1e3)
    elif time_str.endswith("s"):
        return int(_parse_positive_float(time_str[:-1]) * 1e6)
    return int(_parse_positive_float(time_str))