-
Notifications
You must be signed in to change notification settings - Fork 337
/
power_metrics.py
63 lines (57 loc) · 1.62 KB
/
power_metrics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#
# perf power metrics for toplev
#
import os
class EnergyPackage:
name = "Package Energy"
desc = """
Package Energy over measurement period in Joules"""
unit = "Joules"
nogroup = True
subplot = "Power"
domain = "Package"
def compute(self, EV):
self.val = EV("power/energy-pkg/", 1)
self.thresh = self.val > 0
class EnergyCores:
name = "Cores Energy"
desc = """
Cores Energy over measurement period in Joules"""
unit = "Joules"
nogroup = True
subplot = "Power"
domain = "Package"
def compute(self, EV):
self.val = EV("power/energy-cores/", 1)
self.thresh = self.val > 0
class EnergyRAM:
name = "RAM Energy"
desc = """
RAM Energy over measurement period in Joules"""
unit = "Joules"
nogroup = True
subplot = "Power"
domain = "Package"
def compute(self, EV):
self.val = EV("power/energy-ram/", 1)
self.thresh = self.val > 0
class EnergyGPU:
name = "GPU Energy"
desc = """
GPU Energy over measurement period in Joules"""
unit = "Joules"
nogroup = True
subplot = "Power"
domain = "Package"
def compute(self, EV):
self.val = EV("power/energy-gpu/", 1)
self.thresh = self.val > 1
class Setup:
def __init__(self, r):
if os.path.exists("/sys/devices/power/events/energy-cores"):
r.force_metric(EnergyCores())
r.force_metric(EnergyPackage())
if os.path.exists("/sys/devices/power/events/energy-ram"):
r.force_metric(EnergyRAM())
if os.path.exists("/sys/devices/power/events/energy-gpu"):
r.force_metric(EnergyGPU())