When interval is > 0.0 compares system CPU times elapsed before and after the interval (blocking).
When interval is 0.0 or None compares system CPU times elapsed since last call or module import, returning immediately. That means the first time this is called it will return a meaningless 0.0 value which you are supposed to ignore. In this case it is recommended for accuracy that this function be called with at least 0.1 seconds between calls.
从the documentation:
因此,如果通过
interval=1
,它将测量1秒内的CPU利用率。在进行测量时,呼叫将阻塞(可能是睡眠)相关问题 更多 >
编程相关推荐