安裝工具:
首先安裝sysstat
包(含cpustat
工具):
sudo apt update && sudo apt install sysstat
基礎能耗數據采集:
cpustat
輸出中%usr
(用戶態占用)、%sys
(內核態占用)、%idle
(空閑率)等指標可輔助判斷CPU負載與能耗的關聯。cpustat -e
部分硬件支持顯示CPU功耗、溫度等數據(需硬件兼容)。定時與定向分析:
cpustat -I 2 5 > cpu_energy.log
cpustat -p 0,1 # 監控CPU 0和1
結合其他工具綜合分析:
top
或htop
查看高CPU占用進程,定位能耗熱點:sudo apt install top/htop && top
powertop
(需額外安裝)獲取更精確的功耗數據,輔助驗證CPU能耗:sudo apt install powertop && sudo powertop
注意:
cpustat
的能耗數據依賴硬件支持(如Intel RAPL),部分舊設備可能無法直接獲取功耗值,需結合其他工具(如powertop
)分析。