Ubuntu 查询 CPU 功耗的实用方法
核心要点
快速方法与命令
sudo apt-get install powertopsudo powertop(在“Overview/Tunables”页可查看各组件功耗与建议)sudo powertop --csv=powerlog.csv(便于后续分析)sudo apt-get install linux-tools-common linux-tools-genericsudo turbostat --Summary --quiet --Joules --show Pkg_J --interval 1sudo turbostat --Summary --quiet --Joules --show Pkg_J your_cmd [args]sudo apt-get install cpufrequtilscpufreq-info(当前/最小/最大频率与调速器)for f in /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_max_freq; do echo "$f: $(cat $f) kHz"; donesudo apt-get install lm-sensorssensorsupower -i /org/freedesktop/UPower/devices/battery_BAT0(观察 energy-rate 与 energy-full 的变化)upower -i /org/freedesktop/UPower/devices/line_power_AC(观察 power 字段)结果解读与示例
常见问题与限制
sudo turbostat、sudo powertop)。