def filter(self, lock): cpuTable = lock.get_cpus() cpus = cpuTable.keys() for cpu in cpus: time = cpuTable[cpu].time(1) percent = (time * 100.0) / lock.get_exclusive_stats().time(1) if percent > self.percent: return False return True
def get_cpus(): cpuTable = lock.get_cpus() if len(cpuTable) == 0: return '' cpus = cpuTable.keys() time = cpuTable[cpus[0]].time(DEFAULT_NUM_CORES) cpuString = '%u:%.2f%%' % (cpus[0], ( time * 100.0) / lock.get_exclusive_stats().time(DEFAULT_NUM_CORES)) for cpu in cpus[1:]: time = cpuTable[cpu].time(DEFAULT_NUM_CORES) cpuString += ' %u:%.2f%%' % ( cpu, (time * 100.0) / lock.get_exclusive_stats().time(DEFAULT_NUM_CORES)) return cpuString
def filter(self, lock): return len(lock.get_cpus()) > self.count