servo/tests/blink_perf_tests/update.py
Jonathan Schwender ee781b71b4
tests: Vendor blink perf tests (#38654)
Vendors the [blink perf
tests](https://chromium.googlesource.com/chromium/src/+/HEAD/third_party/blink/perf_tests/).
These perf tests are useful to evaluate the performance of servo. 
The license that governs the perf tests is included in the folder. 
Running benchmark cases automatically is left to future work.

The update.py script is taken from mozjs and slightly adapted, so we can
easily filter
(and patch if this should be necessary in the future.

Testing: This PR just adds the perf_tests, but does not use or modify
them in any way.

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-08-17 09:54:04 +00:00

88 lines
2.3 KiB
Python
Executable file
Vendored

#!/usr/bin/env python3
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Adapted from https://github.com/servo/mozjs/blob/main/mozjs-sys/etc/update.py
import os
import shutil
import subprocess
import tempfile
TARGET = "perf_tests"
def extract_tarball(tarball, commit):
print("Extracting tarball.")
if not os.path.exists(tarball):
raise Exception("Tarball not found at %s" % tarball)
with tempfile.TemporaryDirectory() as directory:
subprocess.check_call(["tar", "-xf", tarball, "-C", directory])
dirname = os.path.dirname(__file__)
filter_file = os.path.abspath(os.path.join(dirname, "filters.txt"))
subprocess.check_call(
[
"rsync",
"--delete-excluded",
f"--filter=merge {filter_file}",
"--prune-empty-dirs",
"--quiet",
"--recursive",
os.path.join(directory, ""),
os.path.join(dirname, TARGET, ""),
]
)
if commit:
subprocess.check_call(
["git", "add", "--all", TARGET], stdout=subprocess.DEVNULL
)
subprocess.check_call(
["git", "commit", "-s", "-m", "tests: Update blink perf tests."],
stdout=subprocess.DEVNULL,
)
def apply_patches():
print("Applying patches.")
dirname = os.path.dirname(__file__)
patch_dir = os.path.abspath(os.path.join(dirname, "patches"))
patches = sorted(
os.path.join(patch_dir, p)
for p in os.listdir(patch_dir)
if p.endswith(".patch")
)
for p in patches:
print(" Applying patch: %s." % p)
subprocess.check_call(
["git", "apply", "--reject", "--directory=" + TARGET, p],
stdout=subprocess.DEVNULL,
)
def main(args):
extract = None
patch = True
commit = True
for arg in args:
if arg == "--no-patch":
patch = False
elif arg == "--no-commit":
commit = False
else:
extract = arg
if extract:
extract_tarball(os.path.abspath(extract), commit)
if patch:
apply_patches()
if __name__ == "__main__":
import sys
main(sys.argv[1:])