pyufunc.cpu_percent#

pyufunc.cpu_percent(interval=None, percpu=False)#

Return a float representing the current system-wide CPU utilization as a percentage.

Parameters:
  • interval (float) – The interval in seconds to wait before calculating the CPU utilization. Defaults to None. If interval is > 0.0, measures CPU times before and after the interval (blocking). If 0.0 or None, returns the utilization since the last call or module import, returning immediately. That means the first time this is called and return a meaningless 0.0 value (supposed to ignore). In this case it is recommended for accuracy that this function be called with at least 0.1 seconds between calls.

  • percpu (bool) – If True, returns a list of floats representing each logical CPU. Defaults to False.

Note

Example

>>> cpu_percent(interval=None)
Returns:

A float representing the current system-wide CPU utilization as a percentage, or a list of floats if percpu is True.

Return type:

psutil.cpu_percent