diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-01-17 14:05:31 +0100 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-01-17 14:05:57 +0100 |
commit | 23c614d2de259e6926c20069345d634ae1712662 (patch) | |
tree | eefab2588b3e1d4f1421c7ae8d1556a0ee0b5198 /libexec/rapl-to-dfatool.py | |
parent | 10c5ca3b49009ee45ec37b512f31dff0c8adf9ae (diff) |
Add helper to determine system-wide energy and power usage via RAPLmain
To Do: Automatically determine (and subtract) idle power usage
Diffstat (limited to 'libexec/rapl-to-dfatool.py')
-rwxr-xr-x | libexec/rapl-to-dfatool.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libexec/rapl-to-dfatool.py b/libexec/rapl-to-dfatool.py new file mode 100755 index 0000000..5ab4c38 --- /dev/null +++ b/libexec/rapl-to-dfatool.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import sys + + +def main(perf_line, rapl_names, rapl_start, rapl_stop): + duration_ns = int(perf_line.split(",")[3]) + + rapl_names = rapl_names.split() + rapl_start = rapl_start.split() + rapl_stop = rapl_stop.split() + + buf = [f"duration_ns={duration_ns}"] + + for i in range(len(rapl_names)): + uj_start = int(rapl_start[i]) + uj_stop = int(rapl_stop[i]) + buf.append(f"{rapl_names[i]}_energy_uj={uj_stop - uj_start}") + buf.append( + f"{rapl_names[i]}_power_W={(uj_stop - uj_start) * 1000 / duration_ns}" + ) + + print(" ".join(buf)) + + +if __name__ == "__main__": + main(*sys.argv[1:]) |