| Index: chrome/test/vr/perf/latency/motopho_thread.py
|
| diff --git a/chrome/test/vr/perf/latency/motopho_thread.py b/chrome/test/vr/perf/latency/motopho_thread.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8281300f0ebb27bbddc2a87719ad4721e614871b
|
| --- /dev/null
|
| +++ b/chrome/test/vr/perf/latency/motopho_thread.py
|
| @@ -0,0 +1,46 @@
|
| +# Copyright 2017 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +import logging
|
| +import subprocess
|
| +import threading
|
| +
|
| +class MotophoThread(threading.Thread):
|
| + """Handles the running of the Motopho script and extracting results."""
|
| + def __init__(self):
|
| + threading.Thread.__init__(self)
|
| + self._latency = None
|
| + self._max_correlation = None
|
| +
|
| + def run(self):
|
| + motopho_output = ""
|
| + try:
|
| + motopho_output = subprocess.check_output(["./motophopro_nograph"],
|
| + stderr=subprocess.STDOUT)
|
| + except subprocess.CalledProcessError as e:
|
| + logging.error('Failed to run Motopho script: %s', e.output)
|
| + raise e
|
| +
|
| + if "FAIL" in motopho_output:
|
| + logging.error('Failed to get latency, logging raw output: %s',
|
| + motopho_output)
|
| + raise RuntimeError('Failed to get latency - correlation likely too low')
|
| +
|
| + self._latency = None
|
| + self._max_correlation = None
|
| + for line in motopho_output.split("\n"):
|
| + if 'Motion-to-photon latency:' in line:
|
| + self._latency = float(line.split(" ")[-2])
|
| + if 'Max correlation is' in line:
|
| + self._max_correlation = float(line.split(' ')[-1])
|
| + if self._latency and self._max_correlation:
|
| + break;
|
| +
|
| + @property
|
| + def latency(self):
|
| + return self._latency
|
| +
|
| + @property
|
| + def max_correlation(self):
|
| + return self._max_correlation
|
|
|