in mozperftest_tools/mozperftest_tools/side_by_side.py [0:0]
def _find_videos(self, artifact_dir, original=False):
# Find the cold/warm browsertime.json files
cold_path = ""
warm_path = ""
browsertime_json_path = ""
for path in pathlib.Path(artifact_dir).rglob("*browsertime.json"):
if "profiling" not in path.parts:
if "cold" in str(path):
cold_path = path
elif "warm" in str(path):
warm_path = path
else:
browsertime_json_path = path
if cold_path and warm_path:
with cold_path.open() as f:
cold_data = json.load(f)
with warm_path.open() as f:
warm_data = json.load(f)
return {
"cold": [
str(pathlib.Path(cold_path.parents[0], file)).replace(
".mp4", "-original.mp4"
)
if original
else str(pathlib.Path(cold_path.parents[0], file))
for file in cold_data[0]["files"]["video"]
],
"warm": [
str(pathlib.Path(warm_path.parents[0], file)).replace(
".mp4", "-original.mp4"
)
if original
else str(pathlib.Path(warm_path.parents[0], file))
for file in warm_data[0]["files"]["video"]
],
}
elif browsertime_json_path:
with browsertime_json_path.open() as f:
browsertime_data = json.load(f)
return self._split_browsertime_json(
browsertime_json_path, browsertime_data, original
)
else:
raise Exception(
"Cannot find a browsertime.json file for the cold or warm pageloads."
)