mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
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>
This commit is contained in:
parent
0643aa4708
commit
8dd40ed2bd
2 changed files with 56 additions and 6 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue