[fuchsia] dump metric results
c9944b69f2/734
is the metric data and being uploaded to exception-db.
Also several drive-by comment fixes.
Cq-Include-Trybots: luci.chrome.try:fuchsia-ava-nelson
Bug: 40935291
Change-Id: I130bdf41d671e6c3f10a28d1daaa86b4ce165582
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6003211
Reviewed-by: David Song <wintermelons@google.com>
Commit-Queue: Zijie He <zijiehe@google.com>
Cr-Commit-Position: refs/heads/main@{#1381376}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
8cda2cb3ce
commit
b58c02ef9b
@ -57,16 +57,16 @@ def time_consumption(*name_pieces: str) -> TimeConsumption:
|
||||
|
||||
|
||||
def clear() -> None:
|
||||
"""Clear all the registered Measures."""
|
||||
"""Clears all the registered Measures."""
|
||||
_metric.clear()
|
||||
|
||||
|
||||
def size() -> int:
|
||||
"""Get the current size of registered Measures."""
|
||||
"""Gets the current size of registered Measures."""
|
||||
return _metric.size()
|
||||
|
||||
def to_dict() -> dict:
|
||||
"""Convert all the registered Measures to a dict.
|
||||
"""Converts all the registered Measures to a dict.
|
||||
|
||||
The records are wrapped in protobuf Any message before exported as dict
|
||||
so that an additional key "@type" is included.
|
||||
@ -77,7 +77,7 @@ def to_dict() -> dict:
|
||||
|
||||
|
||||
def to_json() -> str:
|
||||
"""Convert all the registered Measures to a json str."""
|
||||
"""Converts all the registered Measures to a json str."""
|
||||
return json.dumps(to_dict(), sort_keys=True, indent=2)
|
||||
|
||||
# TODO(crbug.com/343242386): May need to implement a lock and reset logic to
|
||||
|
@ -31,7 +31,7 @@ import monitors
|
||||
import version
|
||||
from browser_runner import BrowserRunner
|
||||
from chrome_driver_wrapper import ChromeDriverWrapper
|
||||
from common import get_ffx_isolate_dir, get_free_local_port
|
||||
from common import get_build_info, get_ffx_isolate_dir, get_free_local_port
|
||||
from compatible_utils import running_unattended
|
||||
from isolate_daemon import IsolateDaemon
|
||||
from run_webpage_test import WebpageTestRunner, capture_devtools_addr
|
||||
@ -86,55 +86,70 @@ def parameters_of(file: str) -> camera.Parameters:
|
||||
return result
|
||||
|
||||
|
||||
def run_test(proc: subprocess.Popen) -> None:
|
||||
device, port = capture_devtools_addr(proc, LOG_DIR)
|
||||
logging.warning('DevTools is now running on %s:%s', device, port)
|
||||
camera_params = parameters_of('720p24fpsVP9_gangnam_sync.webm')
|
||||
with ChromeDriverWrapper((device, port)) as driver:
|
||||
# Replace the last byte to 1, by default it's the ip address of the host
|
||||
# machine being accessible on the device.
|
||||
host = '.'.join(device.split('.')[:-1] + ['1'])
|
||||
if running_unattended():
|
||||
param = f'file={camera_params.file}'
|
||||
proxy_host = os.environ.get('GCS_PROXY_HOST')
|
||||
if proxy_host:
|
||||
# This is a hacky way to get the ip address of the host machine
|
||||
# being accessible on the device.
|
||||
host = proxy_host + '0'
|
||||
else:
|
||||
param = 'local'
|
||||
driver.get(f'http://{host}:{HTTP_SERVER_PORT}/video.html?{param}')
|
||||
with StartProcess(camera.start, [camera_params], False):
|
||||
video = driver.find_element_by_id('video')
|
||||
video.click()
|
||||
# Video playback should finish almost within the same time as the camera
|
||||
# recording, and this check is only necessary to indicate a very heavy
|
||||
# network laggy and buffering.
|
||||
# TODO(crbug.com/40935291): May need to adjust the strategy here, the
|
||||
# final frame / barcode is considered laggy and drops the score.
|
||||
with monitors.time_consumption('video_perf', 'playback', 'laggy'):
|
||||
while not driver.execute_script('return arguments[0].ended;',
|
||||
video):
|
||||
time.sleep(1)
|
||||
logging.warning('Video finished')
|
||||
def run_video_perf_test(file: str, driver: ChromeDriverWrapper,
|
||||
host: str) -> None:
|
||||
if running_unattended():
|
||||
param = f'file={file}'
|
||||
else:
|
||||
param = 'local'
|
||||
camera_params = parameters_of(file)
|
||||
driver.get(f'http://{host}:{HTTP_SERVER_PORT}/video.html?{param}')
|
||||
with StartProcess(camera.start, [camera_params], False):
|
||||
video = driver.find_element_by_id('video')
|
||||
video.click()
|
||||
# Video playback should finish almost within the same time as the camera
|
||||
# recording, and this check is only necessary to indicate a very heavy
|
||||
# network laggy and buffering.
|
||||
# TODO(crbug.com/40935291): May need to adjust the strategy here, the
|
||||
# final frame / barcode is considered laggy and drops the score.
|
||||
with monitors.time_consumption('video_perf', 'playback', 'laggy', file):
|
||||
while not driver.execute_script('return arguments[0].ended;', video):
|
||||
time.sleep(1)
|
||||
logging.warning('Video %s finished', file)
|
||||
|
||||
# Download the original video file for local comparison.
|
||||
original_video = os.path.join(TEMP_DIR, camera_params.file)
|
||||
original_video = os.path.join(TEMP_DIR, file)
|
||||
assert camera_params.video_file != original_video
|
||||
# The http address should match the one in video.html.
|
||||
urllib.request.urlretrieve(
|
||||
f'http://172.31.186.18/test_site/mediaFiles/videostack/'
|
||||
f'{camera_params.file}', original_video)
|
||||
f'http://172.31.186.18/test_site/mediaFiles/videostack/{file}',
|
||||
original_video)
|
||||
|
||||
results = video_analyzer.from_original_video(camera_params.video_file,
|
||||
original_video)
|
||||
logging.warning('Video analysis result: %s', results)
|
||||
|
||||
def record(key: str) -> None:
|
||||
monitors.average(file, key).record(results[key])
|
||||
|
||||
record('smoothness')
|
||||
record('freezing')
|
||||
record('dropped_frame_count')
|
||||
record('total_frame_count')
|
||||
record('dropped_frame_percentage')
|
||||
logging.warning('Video analysis result of %s: %s', file, results)
|
||||
|
||||
# Move the info csv to the cas-output for debugging purpose. Video files are
|
||||
# huge and will be ignored.
|
||||
shutil.move(camera_params.info_file, LOG_DIR)
|
||||
|
||||
|
||||
def run_test(proc: subprocess.Popen) -> None:
|
||||
device, port = capture_devtools_addr(proc, LOG_DIR)
|
||||
logging.warning('DevTools is now running on %s:%s', device, port)
|
||||
# Replace the last byte to 1, by default it's the ip address of the host
|
||||
# machine being accessible on the device.
|
||||
host = '.'.join(device.split('.')[:-1] + ['1'])
|
||||
if running_unattended():
|
||||
proxy_host = os.environ.get('GCS_PROXY_HOST')
|
||||
if proxy_host:
|
||||
# This is a hacky way to get the ip address of the host machine
|
||||
# being accessible on the device.
|
||||
host = proxy_host + '0'
|
||||
with ChromeDriverWrapper((device, port)) as driver:
|
||||
for file in ['720p24fpsVP9_gangnam_sync.webm']:
|
||||
run_video_perf_test(file, driver, host)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
proc = subprocess.Popen([
|
||||
os.path.join(TEST_SCRIPTS_ROOT,
|
||||
@ -150,6 +165,9 @@ def main() -> int:
|
||||
finally:
|
||||
proc.terminate()
|
||||
proc.wait()
|
||||
# May need to merge with the existing file created by run_test.py
|
||||
# webpage process.
|
||||
monitors.dump(os.path.join(LOG_DIR, 'invocations'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -163,6 +181,7 @@ if __name__ == '__main__':
|
||||
# command line flags.
|
||||
logging.warning('Chrome version %s %s', version.chrome_version_str(),
|
||||
version.git_revision())
|
||||
logging.warning('Fuchsia build info %s', get_build_info())
|
||||
# Setting a temporary isolate daemon dir and share it with the webpage
|
||||
# runner.
|
||||
with StartProcess(server.start, [HTTP_SERVER_PORT], True), \
|
||||
|
@ -36,7 +36,7 @@ class Parameters:
|
||||
def start(parameters: Parameters) -> None:
|
||||
"""Starts an av_sync_record process to record the video from the camera.
|
||||
Executing of this function shouldn't be terminated as it would create a
|
||||
bad constructed mp4 file. If the recorder binary does not exist, the
|
||||
bad constructed video file. If the recorder binary does not exist, the
|
||||
function returns immediately."""
|
||||
assert parameters.output_path
|
||||
assert parameters.file
|
||||
|
Reference in New Issue
Block a user