RAPL
This commit is contained in:
parent
c9dc2a306e
commit
b3f7476b82
4 changed files with 152 additions and 25 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
||||||
netreplay
|
netreplay
|
||||||
|
powercap
|
||||||
__pycache__
|
__pycache__
|
||||||
rpxy_*
|
rpxy_*
|
||||||
records/
|
records/
|
||||||
|
|
|
||||||
|
|
@ -352,6 +352,13 @@ python exp.py run local
|
||||||
python plots.py prof <path/to/log>
|
python plots.py prof <path/to/log>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### RAPL
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gcc -O3 powercap.c -o powercap
|
||||||
|
sudo chmod u+s powercap
|
||||||
|
```
|
||||||
|
|
||||||
## Problems
|
## Problems
|
||||||
|
|
||||||
### Youtube
|
### Youtube
|
||||||
|
|
|
||||||
145
exp.py
145
exp.py
|
|
@ -4,15 +4,18 @@ import os, sys, subprocess
|
||||||
CONFIGS = {
|
CONFIGS = {
|
||||||
"debug": {
|
"debug": {
|
||||||
"experiments": [
|
"experiments": [
|
||||||
|
"impl-cipher-ver",
|
||||||
|
"impl-cert-ver",
|
||||||
|
"impl-kex-ver",
|
||||||
"zrtt",
|
"zrtt",
|
||||||
],
|
],
|
||||||
"setups": [
|
"setups": [
|
||||||
#"none-local",
|
"none-local",
|
||||||
"client-local",
|
"client-local",
|
||||||
#"server-local",
|
"server-local",
|
||||||
],
|
],
|
||||||
"records": [
|
"records": [
|
||||||
{ "filename": "youtube", "repeat": 1 },
|
{ "filename": "wikipedia", "repeat": 1 },
|
||||||
],
|
],
|
||||||
"repodir": "/home/tuxmain/reps/tlsbench",
|
"repodir": "/home/tuxmain/reps/tlsbench",
|
||||||
"expdir": "/dev/shm/exp",
|
"expdir": "/dev/shm/exp",
|
||||||
|
|
@ -22,6 +25,7 @@ CONFIGS = {
|
||||||
"p2_repodir": "/home/tuxmain/reps/tlsbench",
|
"p2_repodir": "/home/tuxmain/reps/tlsbench",
|
||||||
"wattmeter": False,
|
"wattmeter": False,
|
||||||
"perf": False,
|
"perf": False,
|
||||||
|
"rapl": False,
|
||||||
"perf_dir": "/home/tuxmain/.cache/exp",
|
"perf_dir": "/home/tuxmain/.cache/exp",
|
||||||
"p3_suffix": ".localhost",
|
"p3_suffix": ".localhost",
|
||||||
"p3_port_plain": 8080,
|
"p3_port_plain": 8080,
|
||||||
|
|
@ -50,6 +54,7 @@ CONFIGS = {
|
||||||
"p2_repodir": "/home/tuxmain/reps/tlsbench",
|
"p2_repodir": "/home/tuxmain/reps/tlsbench",
|
||||||
"wattmeter": False,
|
"wattmeter": False,
|
||||||
"perf": True,
|
"perf": True,
|
||||||
|
"rapl": False,
|
||||||
"perf_dir": "/home/tuxmain/.cache/exp",
|
"perf_dir": "/home/tuxmain/.cache/exp",
|
||||||
"p3_suffix": ".localhost",
|
"p3_suffix": ".localhost",
|
||||||
"p3_port_plain": 8080,
|
"p3_port_plain": 8080,
|
||||||
|
|
@ -69,7 +74,7 @@ CONFIGS = {
|
||||||
"server",
|
"server",
|
||||||
],
|
],
|
||||||
"records": [
|
"records": [
|
||||||
{ "filename": "youtube", "repeat": 1 },
|
{ "filename": "wikipedia", "repeat": 500 },
|
||||||
],
|
],
|
||||||
"repodir": "/home/tuxmain/reps/tlsbench",
|
"repodir": "/home/tuxmain/reps/tlsbench",
|
||||||
"expdir": "/dev/shm/exp",
|
"expdir": "/dev/shm/exp",
|
||||||
|
|
@ -81,10 +86,11 @@ CONFIGS = {
|
||||||
"p2_repodir": "/home/exp/exp",
|
"p2_repodir": "/home/exp/exp",
|
||||||
"wattmeter": True,
|
"wattmeter": True,
|
||||||
"perf": False,
|
"perf": False,
|
||||||
|
"rapl": False,
|
||||||
"p3_suffix": "",
|
"p3_suffix": "",
|
||||||
"p3_port_plain": 80,
|
"p3_port_plain": 80,
|
||||||
"p3_port_tls": 443,
|
"p3_port_tls": 443,
|
||||||
"idle": "idle - - - - - - - 600.000081539154 0.0 896 4792 0.5399999999999991 -",
|
"idle": "idle - - - - - - - 600.000081539154 0.0 896 4792 0.5399999999999991 0 -",
|
||||||
},
|
},
|
||||||
"pi3-local": {
|
"pi3-local": {
|
||||||
"experiments": [
|
"experiments": [
|
||||||
|
|
@ -108,6 +114,7 @@ CONFIGS = {
|
||||||
"p2_repodir": "/home/exp/exp",
|
"p2_repodir": "/home/exp/exp",
|
||||||
"wattmeter": False,
|
"wattmeter": False,
|
||||||
"perf": True,
|
"perf": True,
|
||||||
|
"rapl": False,
|
||||||
"perf_dir": "/home/exp/.cache/exp",
|
"perf_dir": "/home/exp/.cache/exp",
|
||||||
"p3_suffix": ".localhost",
|
"p3_suffix": ".localhost",
|
||||||
"p3_port_plain": 8080,
|
"p3_port_plain": 8080,
|
||||||
|
|
@ -139,10 +146,11 @@ CONFIGS = {
|
||||||
"p2_repodir": "/home/exp/exp",
|
"p2_repodir": "/home/exp/exp",
|
||||||
"wattmeter": True,
|
"wattmeter": True,
|
||||||
"perf": False,
|
"perf": False,
|
||||||
|
"rapl": False,
|
||||||
"p3_suffix": "",
|
"p3_suffix": "",
|
||||||
"p3_port_plain": 80,
|
"p3_port_plain": 80,
|
||||||
"p3_port_tls": 443,
|
"p3_port_tls": 443,
|
||||||
"idle": "idle - - - - - - - 600.0001013278961 0.0 735 4942 1.7759999999999962 -",
|
"idle": "idle - - - - - - - 600.0001013278961 0.0 735 4942 1.7759999999999962 0 -",
|
||||||
},
|
},
|
||||||
"core2-local": {
|
"core2-local": {
|
||||||
"experiments": [
|
"experiments": [
|
||||||
|
|
@ -166,6 +174,66 @@ CONFIGS = {
|
||||||
"p2_repodir": "/home/exp/exp",
|
"p2_repodir": "/home/exp/exp",
|
||||||
"wattmeter": False,
|
"wattmeter": False,
|
||||||
"perf": True,
|
"perf": True,
|
||||||
|
"rapl": False,
|
||||||
|
"perf_dir": "/home/exp/.cache/exp",
|
||||||
|
"p3_suffix": ".localhost",
|
||||||
|
"p3_port_plain": 8080,
|
||||||
|
"p3_port_tls": 8443,
|
||||||
|
},
|
||||||
|
# i7-4790 -> i5-7300HQ
|
||||||
|
"i5": {
|
||||||
|
"experiments": [
|
||||||
|
"impl-cipher-ver",
|
||||||
|
"impl-cert-ver",
|
||||||
|
"impl-kex-ver",
|
||||||
|
],
|
||||||
|
"setups": [
|
||||||
|
"none",
|
||||||
|
"client",
|
||||||
|
"server",
|
||||||
|
],
|
||||||
|
"records": [
|
||||||
|
{ "filename": "wikipedia", "repeat": 100 },
|
||||||
|
],
|
||||||
|
"repodir": "/home/tuxmain/reps/tlsbench",
|
||||||
|
"expdir": "/dev/shm/exp",
|
||||||
|
"log_backup_dir": "/home/tuxmain",
|
||||||
|
"p2_hostname": "192.168.3.42",
|
||||||
|
"p2_addr": "192.168.3.42",
|
||||||
|
"p2_ssh": "exp@192.168.3.42",
|
||||||
|
"p2_psw": None,
|
||||||
|
"p2_repodir": "/home/exp/exp",
|
||||||
|
"wattmeter": True,
|
||||||
|
"perf": False,
|
||||||
|
"rapl": True,
|
||||||
|
"p3_suffix": "",
|
||||||
|
"p3_port_plain": 80,
|
||||||
|
"p3_port_tls": 443,
|
||||||
|
"idle": "idle - - - - - - - 600.0001013278961 0.0 735 4942 1.7759999999999962 0 -",
|
||||||
|
},
|
||||||
|
"i5-local": {
|
||||||
|
"experiments": [
|
||||||
|
"impl-cipher-ver",
|
||||||
|
"impl-cert-ver",
|
||||||
|
"impl-kex-ver",
|
||||||
|
],
|
||||||
|
"setups": [
|
||||||
|
"none-local",
|
||||||
|
"client-local",
|
||||||
|
"server-local",
|
||||||
|
],
|
||||||
|
"records": [
|
||||||
|
{ "filename": "wikipedia", "repeat": 10 },
|
||||||
|
],
|
||||||
|
"repodir": "/home/exp/exp",
|
||||||
|
"expdir": "/dev/shm/exp",
|
||||||
|
"log_backup_dir": "/home/exp",
|
||||||
|
"p2_hostname": "localhost",
|
||||||
|
"p2_addr": "127.0.0.1",
|
||||||
|
"p2_repodir": "/home/exp/exp",
|
||||||
|
"wattmeter": False,
|
||||||
|
"perf": True,
|
||||||
|
"rapl": False,
|
||||||
"perf_dir": "/home/exp/.cache/exp",
|
"perf_dir": "/home/exp/.cache/exp",
|
||||||
"p3_suffix": ".localhost",
|
"p3_suffix": ".localhost",
|
||||||
"p3_port_plain": 8080,
|
"p3_port_plain": 8080,
|
||||||
|
|
@ -234,9 +302,10 @@ CERT_SIGN_ALGS = [
|
||||||
IMPLS = [
|
IMPLS = [
|
||||||
"aws_lc", # Amazon's Rust crypto widely used in Rust stuff
|
"aws_lc", # Amazon's Rust crypto widely used in Rust stuff
|
||||||
"boring", # Google's fork of OpenSSL used in Chrome and Android
|
"boring", # Google's fork of OpenSSL used in Chrome and Android
|
||||||
|
"graviola", # New crypto in Rust
|
||||||
"openssl", # widely used
|
"openssl", # widely used
|
||||||
"ring", # used in most Rust stuff
|
"ring", # used in most Rust stuff
|
||||||
#"symcrypt", # Microsoft's crypto
|
"symcrypt", # Microsoft's crypto
|
||||||
#"wolfcrypt" # used in embedded (won't build with rpxy for now)
|
#"wolfcrypt" # used in embedded (won't build with rpxy for now)
|
||||||
]
|
]
|
||||||
# Symmetric ciphers
|
# Symmetric ciphers
|
||||||
|
|
@ -346,7 +415,7 @@ EXPERIMENTS = {
|
||||||
|
|
||||||
# Some algorithms are not available in all implementations
|
# Some algorithms are not available in all implementations
|
||||||
def alg_filter(kex, cert, cipher, impl):
|
def alg_filter(kex, cert, cipher, impl):
|
||||||
if "MLKEM" in kex and impl != "openssl" and impl != "aws_lc":
|
if "MLKEM" in kex and impl != "openssl" and impl != "aws_lc" and impl != "graviola":
|
||||||
return False
|
return False
|
||||||
if kex == "SECP256R1MLKEM768" and impl == "openssl":
|
if kex == "SECP256R1MLKEM768" and impl == "openssl":
|
||||||
return False
|
return False
|
||||||
|
|
@ -584,14 +653,15 @@ def make_rpxy_config(outdir, domains, cryptodir, config_name, p3_suffix, p3_port
|
||||||
))
|
))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def make_everything(expdir, domains, make_ca, p3_suffix, p3_port_plain, p3_port_tls):
|
def make_everything(expdir, domains, make_ca, config_only, p3_suffix, p3_port_plain, p3_port_tls):
|
||||||
os.makedirs(expdir, exist_ok=True)
|
if not config_only:
|
||||||
if expdir[-1] != "/":
|
os.makedirs(expdir, exist_ok=True)
|
||||||
expdir += "/"
|
if expdir[-1] != "/":
|
||||||
for alg in CERT_SIGN_ALGS:
|
expdir += "/"
|
||||||
algdir = expdir+"certs/"+alg
|
for alg in CERT_SIGN_ALGS:
|
||||||
os.makedirs(algdir, exist_ok=True)
|
algdir = expdir+"certs/"+alg
|
||||||
make_certs(algdir, domains, alg, make_ca)
|
os.makedirs(algdir, exist_ok=True)
|
||||||
|
make_certs(algdir, domains, alg, make_ca)
|
||||||
# this will be a symbolic link to the chosen certs directory
|
# this will be a symbolic link to the chosen certs directory
|
||||||
cryptodir = expdir+"current_certs"
|
cryptodir = expdir+"current_certs"
|
||||||
configdir = expdir+"configs/"
|
configdir = expdir+"configs/"
|
||||||
|
|
@ -671,6 +741,15 @@ def get_net_stat(ssh):
|
||||||
bytes_out = int(items[8])
|
bytes_out = int(items[8])
|
||||||
return (bytes_in, bytes_out)
|
return (bytes_in, bytes_out)
|
||||||
|
|
||||||
|
def get_rapl_energy(ssh, expdir):
|
||||||
|
res = ssh_run(ssh, expdir+"/powercap", hide=True)
|
||||||
|
items = res.split("\n")
|
||||||
|
energy = 0
|
||||||
|
for item in items:
|
||||||
|
if item != "" and item != "-1":
|
||||||
|
energy += int(item)
|
||||||
|
return energy
|
||||||
|
|
||||||
def run_exp(config, only_record=None, idle=False):
|
def run_exp(config, only_record=None, idle=False):
|
||||||
ssh = None
|
ssh = None
|
||||||
if "p2_ssh" in config:
|
if "p2_ssh" in config:
|
||||||
|
|
@ -702,7 +781,7 @@ def run_exp(config, only_record=None, idle=False):
|
||||||
logfile_name = "log-"+timestr
|
logfile_name = "log-"+timestr
|
||||||
logfile_path = expdir+"/"+logfile_name
|
logfile_path = expdir+"/"+logfile_name
|
||||||
logfile = open(logfile_path, "w")
|
logfile = open(logfile_path, "w")
|
||||||
logfile.write("exp impl alg kex cipher ed setup record time cpu bytes_in bytes_out Wh prof\n")
|
logfile.write("exp impl alg kex cipher ed setup record time cpu bytes_in bytes_out Wh Wh_rapl prof\n")
|
||||||
logfile.close()
|
logfile.close()
|
||||||
|
|
||||||
perf_dir = ""
|
perf_dir = ""
|
||||||
|
|
@ -715,27 +794,34 @@ def run_exp(config, only_record=None, idle=False):
|
||||||
rpxy_cpu = get_cpu_stat(ssh)
|
rpxy_cpu = get_cpu_stat(ssh)
|
||||||
p2_bytes_in, p2_bytes_out = get_net_stat(ssh)
|
p2_bytes_in, p2_bytes_out = get_net_stat(ssh)
|
||||||
energy = 0
|
energy = 0
|
||||||
|
energy_rapl
|
||||||
if config["wattmeter"]:
|
if config["wattmeter"]:
|
||||||
energy = wattmeter.get_meter()
|
energy = wattmeter.get_meter()
|
||||||
|
if config["rapl"]:
|
||||||
|
energy_rapl = get_rapl_energy(ssh)
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
time.sleep(600)
|
time.sleep(600)
|
||||||
|
|
||||||
end = time.time()
|
end = time.time()
|
||||||
new_energy = 0
|
new_energy = 0
|
||||||
|
new_energy_rapl = 0
|
||||||
if config["wattmeter"]:
|
if config["wattmeter"]:
|
||||||
new_energy = wattmeter.get_meter()
|
new_energy = wattmeter.get_meter()
|
||||||
|
if config["rapl"]:
|
||||||
|
new_energy_rapl = get_rapl_energy(ssh)
|
||||||
new_p2_bytes_in, new_p2_bytes_out = get_net_stat(ssh)
|
new_p2_bytes_in, new_p2_bytes_out = get_net_stat(ssh)
|
||||||
new_rpxy_cpu = get_cpu_stat(ssh)
|
new_rpxy_cpu = get_cpu_stat(ssh)
|
||||||
rpxy_cpu_diff = new_rpxy_cpu - rpxy_cpu
|
rpxy_cpu_diff = new_rpxy_cpu - rpxy_cpu
|
||||||
p2_bytes_in_diff = new_p2_bytes_in - p2_bytes_in
|
p2_bytes_in_diff = new_p2_bytes_in - p2_bytes_in
|
||||||
p2_bytes_out_diff = new_p2_bytes_out - p2_bytes_out
|
p2_bytes_out_diff = new_p2_bytes_out - p2_bytes_out
|
||||||
energy_diff = new_energy - energy
|
energy_diff = new_energy - energy
|
||||||
|
energy_rapl_diff = new_energy_rapl - energy_rapl
|
||||||
time_diff = end - start
|
time_diff = end - start
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
with open(logfile_path, "a") as logfile:
|
with open(logfile_path, "a") as logfile:
|
||||||
logfile.write(f"idle - - - - - - - {time_diff} {rpxy_cpu_diff} {p2_bytes_in_diff} {p2_bytes_out_diff} {energy_diff} -\n")
|
logfile.write(f"idle - - - - - - - {time_diff} {rpxy_cpu_diff} {p2_bytes_in_diff} {p2_bytes_out_diff} {energy_diff} {energy_rapl_diff} -\n")
|
||||||
logfile.close()
|
logfile.close()
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -790,8 +876,11 @@ def run_exp(config, only_record=None, idle=False):
|
||||||
rpxy_cpu = get_cpu_stat(ssh)
|
rpxy_cpu = get_cpu_stat(ssh)
|
||||||
p2_bytes_in, p2_bytes_out = get_net_stat(ssh)
|
p2_bytes_in, p2_bytes_out = get_net_stat(ssh)
|
||||||
energy = 0
|
energy = 0
|
||||||
|
energy_rapl = 0
|
||||||
if config["wattmeter"]:
|
if config["wattmeter"]:
|
||||||
energy = wattmeter.get_meter()
|
energy = wattmeter.get_meter()
|
||||||
|
if config["rapl"]:
|
||||||
|
energy_rapl = get_rapl_energy(ssh)
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
netreplay = run_netreplay(
|
netreplay = run_netreplay(
|
||||||
|
|
@ -841,8 +930,11 @@ def run_exp(config, only_record=None, idle=False):
|
||||||
end = time.time()
|
end = time.time()
|
||||||
|
|
||||||
new_energy = 0
|
new_energy = 0
|
||||||
|
new_energy_rapl = 0
|
||||||
if config["wattmeter"]:
|
if config["wattmeter"]:
|
||||||
new_energy = wattmeter.get_meter()
|
new_energy = wattmeter.get_meter()
|
||||||
|
if config["rapl"]:
|
||||||
|
new_energy_rapl = get_rapl_energy(ssh)
|
||||||
new_p2_bytes_in, new_p2_bytes_out = get_net_stat(ssh)
|
new_p2_bytes_in, new_p2_bytes_out = get_net_stat(ssh)
|
||||||
new_rpxy_cpu = get_cpu_stat(ssh)
|
new_rpxy_cpu = get_cpu_stat(ssh)
|
||||||
record_filename = record["filename"]
|
record_filename = record["filename"]
|
||||||
|
|
@ -850,11 +942,12 @@ def run_exp(config, only_record=None, idle=False):
|
||||||
p2_bytes_in_diff = new_p2_bytes_in - p2_bytes_in
|
p2_bytes_in_diff = new_p2_bytes_in - p2_bytes_in
|
||||||
p2_bytes_out_diff = new_p2_bytes_out - p2_bytes_out
|
p2_bytes_out_diff = new_p2_bytes_out - p2_bytes_out
|
||||||
energy_diff = new_energy - energy
|
energy_diff = new_energy - energy
|
||||||
|
energy_rapl_diff = new_energy_rapl - energy_rapl
|
||||||
time_diff = end - start
|
time_diff = end - start
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
with open(logfile_path, "a") as logfile:
|
with open(logfile_path, "a") as logfile:
|
||||||
logfile.write(f"{expname} {impl} {alg} {kex} {cipher} {earlydata} {setup} {record_filename} {time_diff} {rpxy_cpu_diff} {p2_bytes_in_diff} {p2_bytes_out_diff} {energy_diff} {prof_filename}\n")
|
logfile.write(f"{expname} {impl} {alg} {kex} {cipher} {earlydata} {setup} {record_filename} {time_diff} {rpxy_cpu_diff} {p2_bytes_in_diff} {p2_bytes_out_diff} {energy_diff} {energy_rapl_diff} {prof_filename}\n")
|
||||||
logfile.close()
|
logfile.close()
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -909,14 +1002,15 @@ def connect_ssh(config):
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) < 2 or sys.argv[1] in ["h", "help", "?", "-h", "-help", "--help", "/?"]:
|
if len(sys.argv) < 2 or sys.argv[1] in ["h", "help", "?", "-h", "-help", "--help", "/?"]:
|
||||||
print("""Options:
|
print("""Options:
|
||||||
make <config> [-c] Create everything
|
make <config> [-c] [-o] Create everything
|
||||||
cert <config> <alg> Select cert signature algorithm
|
cert <config> <alg> Select cert signature algorithm
|
||||||
send <config> Send configs and certs to p2
|
send <config> Send configs and certs to p2
|
||||||
update-certs <config> Update system's certs
|
update-certs <config> Update system's certs
|
||||||
run <config> Run experiment
|
run <config> Run experiment
|
||||||
|
|
||||||
Make options:
|
Make options:
|
||||||
-c Make CA cert (otherwise use already existing one)
|
-c Make CA cert (otherwise use already existing one)
|
||||||
|
-o Make only configs (do not make certs)
|
||||||
|
|
||||||
Cert options:
|
Cert options:
|
||||||
<alg> One of: {sig_algs}
|
<alg> One of: {sig_algs}
|
||||||
|
|
@ -940,7 +1034,8 @@ Run options:
|
||||||
if opt == "make":
|
if opt == "make":
|
||||||
config = CONFIGS[sys.argv[2]]
|
config = CONFIGS[sys.argv[2]]
|
||||||
make_ca = "-c" in sys.argv
|
make_ca = "-c" in sys.argv
|
||||||
make_everything(config["expdir"], DOMAINS, make_ca, config["p3_suffix"], config["p3_port_plain"], config["p3_port_tls"])
|
config_only = "-o" in sys.argv
|
||||||
|
make_everything(config["expdir"], DOMAINS, make_ca, config_only, config["p3_suffix"], config["p3_port_plain"], config["p3_port_tls"])
|
||||||
elif opt == "cert":
|
elif opt == "cert":
|
||||||
alg = sys.argv[3]
|
alg = sys.argv[3]
|
||||||
if not alg in CERT_SIGN_ALGS:
|
if not alg in CERT_SIGN_ALGS:
|
||||||
|
|
|
||||||
24
powercap.c
Normal file
24
powercap.c
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
// gcc -O3 powercap.c -o powercap
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void read_energy(char *path) {
|
||||||
|
FILE *fd = fopen(path, "r");
|
||||||
|
if(fd) {
|
||||||
|
char buf[32];
|
||||||
|
int len = fread(buf, 1, 31, fd);
|
||||||
|
fclose(fd);
|
||||||
|
buf[len] = 0;
|
||||||
|
printf("%s", buf);
|
||||||
|
} else {
|
||||||
|
printf("-1\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
read_energy("/sys/class/powercap/intel-rapl/subsystem/intel-rapl:0:0/energy_uj");
|
||||||
|
read_energy("/sys/class/powercap/intel-rapl/subsystem/intel-rapl:0:1/energy_uj");
|
||||||
|
read_energy("/sys/class/powercap/intel-rapl/subsystem/intel-rapl:0:2/energy_uj");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue