def usage_percent(used, total, _round=None):
    try:
        ret = (used / total) * 100
    except ZeroDivisionError:
        ret = 0.0 if isinstance(used, float) or isinstance(total, float) else 0
    if _round is not None:
        return round(ret, _round)
    else:
        return ret
Calculate percentage usage of 'used' against 'total'.
dataset/ETHPy150Open giampaolo/psutil/psutil/_common.py/usage_percent