def get(self, estimate=False): while True: current = SystemCpuLoadValue() last = self.searchLast(current) if last: break if estimate: return None else: sleep(SYSLOAD_SLEEP) # Store value self.datas.append(current) # Compute system load: 100% - idle percent data = listDiff(last.data, current.data) load = 1.0 - float(data[3]) / sum(data) return load
def isValid(self, item, current): data = listDiff(item.data, current.data) return (self.min_cycles <= sum(data)) \ and (self.min_duration < current.timestamp - item.timestamp)