安装工具:
首先安装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)分析。