Python psutilとトップ

Python psutilとトップ

top命令で測定したCPUの割合と命令で測定したCPUの割合の違いが混乱しています。psutil.cpu_percent

以下は、同じ秒の2つのサンプルです。

Python

 >>> while pct := psutil.cpu_percent(interval=2) :
 ...   print(pct)
 ... 
 6.9
 8.2
 7.0
 7.3
 7.0
 8.7
 9.2
 11.2

最も高い測定値は6.9です。これは次のように指定されます。Return a float representing the current **system-wide** CPU utilization as a percentage.

トップ

これは、コマンドの2回目の繰り返しからの%CPU列ですtop

 %CPU
 29.4
 5.9
 5.9
 0.0

%CPUとして任命 The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.

この二つの表現がなぜそんなに違うのですか?

ベストアンサー1

おすすめ記事