functions: optimisation of 'cpus_online' built-in function
Now it operates over CPU sets parsed from /sys/devices/system/cpu/online and it no more checks each CPU from the list individually for its online status. Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
This commit is contained in:
parent
b7981e7b5e
commit
246854f524
1 changed files with 3 additions and 2 deletions
|
|
@ -17,5 +17,6 @@ class cpus_online(base.Function):
|
|||
def execute(self, args):
|
||||
if not super(self.__class__, self).execute(args):
|
||||
return None
|
||||
cpus = ",".join(args)
|
||||
return ",".join(filter(lambda cpu: self._cmd.is_cpu_online(cpu), cpus.split(",")))
|
||||
cpus = self._cmd.cpulist_unpack(",".join(args))
|
||||
online = self._cmd.cpulist_unpack(self._cmd.read_file("/sys/devices/system/cpu/online"))
|
||||
return ",".join(str(v) for v in set(cpus).intersection(set(online)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue