Bench: --plug hp — the HP t740 (demo-hp) is on a metered plug too
gates / gates (push) Successful in 6m51s
gates / gates (push) Successful in 6m51s
plugmeter.py and plugswitch.py take --plug n100|hp (plug.json / plug-hp.json, outside the repo). The HP plug read 23-33 W while the box started its three guests.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py status
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py off
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py on
|
||||
~/.venvs/plugmeter/bin/python scripts/bench/plugswitch.py status --plug hp # the HP t740's plug
|
||||
|
||||
Reads ~/.config/felhom-bench/plug.json (the same file plugmeter.py reads). `off` also needs, in that file:
|
||||
"standby_w": the plug's measured reading with the machine powered off (the A2 figure);
|
||||
@@ -18,14 +19,14 @@ The key and the device id are never printed. Pinned by scripts/bench/test_plugsw
|
||||
"""
|
||||
import json, os, subprocess, sys, time
|
||||
|
||||
CONF = os.path.expanduser('~/.config/felhom-bench/plug.json')
|
||||
PLUG_FILES = {'n100': 'plug.json', 'hp': 'plug-hp.json'} # --plug, as plugmeter.py
|
||||
WINDOW_S = 20
|
||||
STEP_S = 2
|
||||
MARGIN_W = 1.0
|
||||
|
||||
|
||||
def load():
|
||||
return json.load(open(CONF))
|
||||
def load(plug='n100'):
|
||||
return json.load(open(os.path.expanduser('~/.config/felhom-bench/' + PLUG_FILES[plug])))
|
||||
|
||||
|
||||
def device(c):
|
||||
@@ -71,11 +72,14 @@ def off_allowed(samples, standby_w, window_s=WINDOW_S):
|
||||
|
||||
|
||||
def main(argv):
|
||||
plug = 'n100'
|
||||
if len(argv) == 4 and argv[2] == '--plug' and argv[3] in PLUG_FILES:
|
||||
plug, argv = argv[3], argv[:2]
|
||||
if len(argv) != 2 or argv[1] not in ('on', 'off', 'status'):
|
||||
print('usage: plugswitch.py on|off|status', file=sys.stderr)
|
||||
print('usage: plugswitch.py on|off|status [--plug n100|hp]', file=sys.stderr)
|
||||
return 64
|
||||
cmd = argv[1]
|
||||
c = load()
|
||||
c = load(plug)
|
||||
dev = device(c)
|
||||
if cmd == 'status':
|
||||
w, on = read_watts(dev, c)
|
||||
|
||||
Reference in New Issue
Block a user