From 1cf624ba038a5fe426b2a7a3c1f750538a73808a Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 31 Jan 2023 10:42:15 +0100 Subject: [PATCH] [tools] Improve run_perf.py - Mark run_perf.py executable - Add more user-friendly option --d8-path aliase - Add --repeat alias that matches the go/crossbench flag - Handle symlinks for d8-directory using pathlib - Only print timeout message if the result has timed_out == True - Add .DS_Store to gitignore Change-Id: Ia0fb0b926632af4b520d3aaf447e5bd35723816e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4205910 Commit-Queue: Camillo Bruni Reviewed-by: Alexander Schulze Cr-Commit-Position: refs/heads/main@{#85555} --- .gitignore | 1 + tools/run_perf.py | 32 ++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) mode change 100644 => 100755 tools/run_perf.py diff --git a/.gitignore b/.gitignore index 99ce6d6631..3074da15d0 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ .clangd .cpplint-cache .cproject +.DS_Store .gclient_entries .gdb_history .idea diff --git a/tools/run_perf.py b/tools/run_perf.py old mode 100644 new mode 100755 index 9313d5715c..7b4ab418ae --- a/tools/run_perf.py +++ b/tools/run_perf.py @@ -127,6 +127,7 @@ import json import logging import math import argparse +import pathlib import os import re import subprocess @@ -787,6 +788,7 @@ class Platform(object): if output.stderr: # pragma: no cover # Print stderr for debugging. logging.info(title % 'Stderr' + '\n%s', output.stderr) + if output.HasTimedOut(): logging.warning('>>> Test timed out after %ss.', runnable.timeout) if output.exit_code != 0: logging.warning('>>> Test crashed with exit code %d.', output.exit_code) @@ -1076,10 +1078,12 @@ def Main(argv): parser.add_argument('--outdir-secondary', help='Base directory with compile output without patch ' 'or for reference build') - parser.add_argument('--binary-override-path', - help='JavaScript engine binary. By default, d8 under ' - 'architecture-specific build dir. ' - 'Not supported in conjunction with outdir-secondary.') + parser.add_argument( + '--binary-override-path', + '--d8-path', + help='JavaScript engine binary. By default, d8 under ' + 'architecture-specific build dir. ' + 'Not supported in conjunction with outdir-secondary.') parser.add_argument('--prioritize', help='Raise the priority to nice -20 for the ' 'benchmarking process.Requires Linux, schedtool, and ' @@ -1123,9 +1127,13 @@ def Main(argv): parser.add_argument('--dump-logcats-to', help='Writes logcat output from each test into specified ' 'directory. Only supported for android targets.') - parser.add_argument('--run-count', type=int, default=0, - help='Override the run count specified by the test ' - 'suite. The default 0 uses the suite\'s config.') + parser.add_argument( + '--run-count', + "--repeat", + type=int, + default=0, + help='Override the run count specified by the test ' + 'suite. The default 0 uses the suite\'s config.') parser.add_argument( '--dry-run', default=False, @@ -1164,15 +1172,15 @@ def Main(argv): os.path.join(workspace, args.outdir), args.arch) default_binary_name = 'd8' else: - if not os.path.isfile(args.binary_override_path): - logging.error('binary-override-path must be a file name') + path = pathlib.Path(args.binary_override_path).expanduser().resolve() + if not path.is_file(): + logging.error(f'binary-override-path "{path}" must be a file name') return INFRA_FAILURE_RETCODE if args.outdir_secondary: logging.error('specify either binary-override-path or outdir-secondary') return INFRA_FAILURE_RETCODE - args.shell_dir = os.path.abspath( - os.path.dirname(args.binary_override_path)) - default_binary_name = os.path.basename(args.binary_override_path) + args.shell_dir = str(path.parent) + default_binary_name = path.name if args.outdir_secondary: args.shell_dir_secondary = find_build_directory(