summaryrefslogtreecommitdiff
path: root/bin/calibrate.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-12-28 17:12:41 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-12-28 17:12:41 +0100
commit56597a6a68e741355b301f91d5913d59cfb34eaa (patch)
tree7531e41faf62f126984bf05b8d712f99c9520d5d /bin/calibrate.py
parent56337453f0f3fbe34255e636d5d65974f4d17681 (diff)
New upstream version 3.1.2upstream/3.1.2upstream
Diffstat (limited to 'bin/calibrate.py')
-rw-r--r--bin/calibrate.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/bin/calibrate.py b/bin/calibrate.py
index 3f9104e..be06a54 100644
--- a/bin/calibrate.py
+++ b/bin/calibrate.py
@@ -28,8 +28,8 @@ import re
import subprocess
import sys
-variable_re = re.compile('^VARIABLE: (.*)$', re.M)
-elapsed_re = re.compile('^ELAPSED: (.*)$', re.M)
+variable_re = re.compile(r'^VARIABLE: (.*)$', re.M)
+elapsed_re = re.compile(r'^ELAPSED: (.*)$', re.M)
def main(argv=None):
if argv is None:
@@ -60,7 +60,8 @@ def main(argv=None):
while good < 3:
p = subprocess.Popen(command,
stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
+ stderr=subprocess.STDOUT,
+ universal_newlines=True)
output = p.communicate()[0]
vm = variable_re.search(output)
em = elapsed_re.search(output)
@@ -70,12 +71,13 @@ def main(argv=None):
print(output)
raise
print("run %3d: %7.3f: %s" % (run, elapsed, ' '.join(vm.groups())))
- if opts.min < elapsed and elapsed < opts.max:
+ if opts.min < elapsed < opts.max:
good += 1
else:
good = 0
for v in vm.groups():
var, value = v.split('=', 1)
+ # TODO: this sometimes converges slowly, better algorithm?
value = int((int(value) * opts.max) // elapsed)
os.environ[var] = str(value)
run += 1