aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo
diff options
context:
space:
mode:
authorSamson <16504129+sagudev@users.noreply.github.com>2024-08-29 17:58:57 +0200
committerGitHub <noreply@github.com>2024-08-29 15:58:57 +0000
commit8dd40ed2bd4411d73ca1661803635345c2d9c3c1 (patch)
treee5918205e5c6232b95236398ebb67335c931a234 /python/servo
parent0643aa47089838353e80f6fd509cbe70d13af271 (diff)
downloadservo-8dd40ed2bd4411d73ca1661803635345c2d9c3c1.tar.gz
servo-8dd40ed2bd4411d73ca1661803635345c2d9c3c1.zip
mach: Add `test-speedometer` command and `--bmf-output` to speedometer and dromaeo (#33247)
* Allow exporting Dromaeo results as BMF JSON Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Add speedometer runner Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Diffstat (limited to 'python/servo')
-rw-r--r--python/servo/testing_commands.py49
1 files changed, 45 insertions, 4 deletions
diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py
index fb7f1e22931..0e08f84c3ea 100644
--- a/python/servo/testing_commands.py
+++ b/python/servo/testing_commands.py
@@ -16,6 +16,7 @@ import os.path as path
import shutil
import subprocess
import textwrap
+import json
from python.servo.post_build_commands import PostBuildCommands
import wpt
@@ -402,9 +403,16 @@ class MachCommands(CommandBase):
@Command('test-dromaeo', description='Run the Dromaeo test suite', category='testing')
@CommandArgument('tests', default=["recommended"], nargs="...", help="Specific tests to run")
+ @CommandArgument('--bmf-output', default=None, help="Specify BMF JSON output file")
@CommandBase.common_command_arguments(binary_selection=True)
- def test_dromaeo(self, tests, servo_binary: str):
- return self.dromaeo_test_runner(tests, servo_binary)
+ def test_dromaeo(self, tests, servo_binary: str, bmf_output: str | None = None):
+ return self.dromaeo_test_runner(tests, servo_binary, bmf_output)
+
+ @Command('test-speedometer', description="Run servo's speedometer", category='testing')
+ @CommandArgument('--bmf-output', default=None, help="Specify BMF JSON output file")
+ @CommandBase.common_command_arguments(binary_selection=True)
+ def test_speedometer(self, servo_binary: str, bmf_output: str | None = None):
+ return self.speedometer_runner(servo_binary, bmf_output)
@Command('update-jquery',
description='Update the jQuery test suite expected results',
@@ -488,10 +496,14 @@ class MachCommands(CommandBase):
return call([run_file, cmd, bin_path, base_dir])
- def dromaeo_test_runner(self, tests, binary: str):
+ def dromaeo_test_runner(self, tests, binary: str, bmf_output: str | None):
base_dir = path.abspath(path.join("tests", "dromaeo"))
dromaeo_dir = path.join(base_dir, "dromaeo")
run_file = path.join(base_dir, "run_dromaeo.py")
+ if bmf_output:
+ bmf_output = path.abspath(bmf_output)
+ else:
+ bmf_output = ""
# Clone the Dromaeo repository if it doesn't exist
if not os.path.isdir(dromaeo_dir):
@@ -510,7 +522,36 @@ class MachCommands(CommandBase):
bin_path = path.abspath(binary)
return check_call(
- [run_file, "|".join(tests), bin_path, base_dir])
+ [run_file, "|".join(tests), bin_path, base_dir, bmf_output])
+
+ def speedometer_runner(self, binary: str, bmf_output: str | None):
+ speedometer = json.loads(subprocess.check_output([
+ binary,
+ "https://servospeedometer.netlify.app?headless=1",
+ "--pref", "dom.allow_scripts_to_close_windows",
+ "--resolution=1100x900",
+ "--headless"], timeout=60).decode())
+
+ print(f"Score: {speedometer['Score']['mean']} ± {speedometer['Score']['delta']}")
+
+ if bmf_output:
+ output = dict()
+
+ def parse_speedometer_result(result):
+ output[f"Speedometer/{result['name']}"] = {
+ 'latency': { # speedometer has ms we need to convert to ns
+ 'value': float(result['mean']) * 1000.0,
+ 'lower_value': float(result['min']) * 1000.0,
+ 'upper_value': float(result['max']) * 1000.0,
+ }
+ }
+ for child in result['children']:
+ parse_speedometer_result(child)
+
+ for v in speedometer.values():
+ parse_speedometer_result(v)
+ with open(bmf_output, 'w', encoding='utf-8') as f:
+ json.dump(output, f, indent=4)
def create_parser_create():