def calculatecpu(timesa, timesb):
    for i in range(len(timesa)):
        timesb[i] -= timesa[i]
    total = sum(timesb)
    if total == 0:
        return 0.0
    else:
        # subtract % time spent in idle time
        return 100 - ((100.0 * timesb[-1]) / total)

# end move these to core.misc.utils
dataset/ETHPy150Open coreemu/core/daemon/examples/netns/wlanemanetests.py/calculatecpu/original