py rapl
1.0.0
py-rapl
是一个非常简单的库,支持对 RAPL 或运行平均功率限制能量计数器进行采样,大多数(如果不是全部)现代 Intel CPU 都提供该计数器。
import rapl
s1 = rapl.RAPLMonitor.sample()
# Some work that you want to measure.
s2 = rapl.RAPLMonitor.sample()
# Take the difference of the samples
diff = s2 - s1
# Print the difference in microjoules
print(diff.energy("package-0", "core", rapl.UJOULES))
# Print the average power
print(diff.average_power("package-0", "core"))