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"))