

def getCpuUsage():
    global lastUsage, lastUsageTime
    rusage = getrusage(RUSAGE_SELF)
    currentUsage = (rusage.ru_utime + rusage.ru_stime)
    currentTime = time.time()
    usageDiff = (currentUsage - lastUsage)
    timeDiff = (currentTime - lastUsageTime)
    if (currentTime == 0):
        timeDiff = 1e-06
    cpuUsagePercent = ((usageDiff / timeDiff) * 100.0)
    lastUsage = currentUsage
    lastUsageTime = currentTime
    return cpuUsagePercent

dataset/ETHPy150Open tmm1/graphite/carbon/lib/carbon/instrumentation.py getCpuUsage/VarMisuse@59/91 `timeDiff`->`currentTime`