Changeset 239522 in webkit


Ignore:
Timestamp:
Dec 21, 2018 3:26:05 PM (5 years ago)
Author:
Simon Fraser
Message:

Add support to run-benchmark to use non-default copies of the browser apps
https://bugs.webkit.org/show_bug.cgi?id=192905
rdar://problem/46845840

Reviewed by Dewei Zhu.

Add support for a --browser-path argument to run-benchmark, which allows you to use
a custom app bundle for a given browser (only implemented for Safari at present).

  • Scripts/webkitpy/benchmark_runner/benchmark_runner.py:

(BenchmarkRunner.init):

  • Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver.py:

(BrowserDriver.init):

  • Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver_factory.py:

(BrowserDriverFactory.create):

  • Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:

(OSXBrowserDriver._launch_process):
(OSXBrowserDriver._launch_process_with_caffeinate): Fix spelling.
(OSXBrowserDriver._launch_process_with_caffinate): Deleted.

  • Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py:

(OSXChromeCanaryDriver.launch_url):

  • Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py:

(OSXFirefoxNightlyDriver.launch_url):

  • Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py:

(OSXSafariDriver.init):
(OSXSafariDriver.launch_url):

  • Scripts/webkitpy/benchmark_runner/run_benchmark.py:

(parse_args):
(run_benchmark_plan):

  • Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py:

(WebServerBenchmarkRunner.init):

  • Scripts/webkitpy/browserperfdash/browserperfdash_unittest.py:

(FakeBenchmarkRunner.init):

Location:
trunk/Tools
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r239520 r239522  
     12018-12-19  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Add support to run-benchmark to use non-default copies of the browser apps
     4        https://bugs.webkit.org/show_bug.cgi?id=192905
     5        rdar://problem/46845840
     6
     7        Reviewed by Dewei Zhu.
     8       
     9        Add support for a --browser-path argument to run-benchmark, which allows you to use
     10        a custom app bundle for a given browser (only implemented for Safari at present).
     11
     12        * Scripts/webkitpy/benchmark_runner/benchmark_runner.py:
     13        (BenchmarkRunner.__init__):
     14        * Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver.py:
     15        (BrowserDriver.__init__):
     16        * Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver_factory.py:
     17        (BrowserDriverFactory.create):
     18        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:
     19        (OSXBrowserDriver._launch_process):
     20        (OSXBrowserDriver._launch_process_with_caffeinate): Fix spelling.
     21        (OSXBrowserDriver._launch_process_with_caffinate): Deleted.
     22        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py:
     23        (OSXChromeCanaryDriver.launch_url):
     24        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py:
     25        (OSXFirefoxNightlyDriver.launch_url):
     26        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py:
     27        (OSXSafariDriver.__init__):
     28        (OSXSafariDriver.launch_url):
     29        * Scripts/webkitpy/benchmark_runner/run_benchmark.py:
     30        (parse_args):
     31        (run_benchmark_plan):
     32        * Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py:
     33        (WebServerBenchmarkRunner.__init__):
     34        * Scripts/webkitpy/browserperfdash/browserperfdash_unittest.py:
     35        (FakeBenchmarkRunner.__init__):
     36
    1372018-12-21  Jiewen Tan  <jiewen_tan@apple.com>
    238
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py

    • Property svn:executable set to *
    r227739 r239522  
    2424    name = 'benchmark_runner'
    2525
    26     def __init__(self, plan_file, local_copy, count_override, build_dir, output_file, platform, browser, scale_unit=True, show_iteration_values=False, device_id=None):
     26    def __init__(self, plan_file, local_copy, count_override, build_dir, output_file, platform, browser, browser_path, scale_unit=True, show_iteration_values=False, device_id=None):
    2727        try:
    2828            plan_file = self._find_plan_file(plan_file)
     
    3737                    self._plan['count'] = count_override
    3838                self._browser_driver = BrowserDriverFactory.create(platform, browser)
     39                self._browser_path = browser_path
    3940                self._build_dir = os.path.abspath(build_dir) if build_dir else None
    4041                self._output_file = output_file
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver.py

    • Property svn:executable set to *
    r219853 r239522  
    1616
    1717    @abstractmethod
    18     def launch_url(self, url, options, browser_build_path=None):
     18    def launch_url(self, url, options, browser_build_path=None, browser_path=None):
    1919        pass
    2020
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver_factory.py

    • Property svn:executable set to *
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py

    r221656 r239522  
    8989                            browser_retcode=self._browser_process.returncode))
    9090
    91     def launch_url(self, url, options, browser_build_path):
     91    def launch_url(self, url, options, browser_build_path, browser_path):
    9292        if not self._browser_arguments:
    9393            self._browser_arguments = [url]
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py

    r221655 r239522  
    3434    process_search_list = ['chromium', 'chromium-browser', 'chrome']
    3535
    36     def launch_url(self, url, options, browser_build_path):
     36    def launch_url(self, url, options, browser_build_path, browser_path):
    3737        self._browser_arguments = ['--temp-profile', '--start-maximized',
    3838                                   '--homepage', url]
    39         super(LinuxChromeDriver, self).launch_url(url, options, browser_build_path)
     39        super(LinuxChromeDriver, self).launch_url(url, options, browser_build_path, browser_path)
    4040
    4141    def launch_driver(self, url, options, browser_build_path):
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_epiphany_driver.py

    r219850 r239522  
    3232    process_search_list = ['epiphany', 'epiphany-browser']
    3333
    34     def launch_url(self, url, options, browser_build_path):
     34    def launch_url(self, url, options, browser_build_path, browser_path):
    3535        self._browser_arguments = ['--new-window', '-p',
    3636                                   '--profile={profile}'.format(profile=self._temp_profiledir),
    3737                                   url]
    38         super(EpiphanyBrowserDriver, self).launch_url(url, options, browser_build_path)
     38        super(EpiphanyBrowserDriver, self).launch_url(url, options, browser_build_path, browser_path)
    3939
    4040    def launch_driver(self, url, options, browser_build_path):
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py

    r221655 r239522  
    3434    process_search_list = ['firefox', 'firefox-bin']
    3535
    36     def launch_url(self, url, options, browser_build_path):
     36    def launch_url(self, url, options, browser_build_path, browser_path):
    3737        self._browser_arguments = ['-new-instance', '-profile', self._temp_profiledir,
    3838                                   '-width', str(self._screen_size().width),
    3939                                   '-height', str(self._screen_size().height),
    4040                                   url]
    41         super(LinuxFirefoxDriver, self).launch_url(url, options, browser_build_path)
     41        super(LinuxFirefoxDriver, self).launch_url(url, options, browser_build_path, browser_path)
    4242
    4343    def launch_driver(self, url, options, browser_build_path):
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_minibrowsergtk_driver.py

    r219850 r239522  
    3232    process_search_list = ['Tools/Scripts/run-minibrowser', 'MiniBrowser']
    3333
    34     def launch_url(self, url, options, browser_build_path):
     34    def launch_url(self, url, options, browser_build_path, browser_path):
    3535        self._browser_arguments = []
    3636        if self.process_name.endswith('run-minibrowser'):
     
    3838        self._browser_arguments.append('--geometry={w}x{h}'.format(w=self._screen_size().width, h=self._screen_size().height))
    3939        self._browser_arguments.append(url)
    40         super(GTKMiniBrowserDriver, self).launch_url(url, options, browser_build_path)
     40        super(GTKMiniBrowserDriver, self).launch_url(url, options, browser_build_path, browser_path)
    4141
    4242    def launch_driver(self, url, options, browser_build_path):
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py

    r221656 r239522  
    4141        # FIXME: May need to be modified for a local build such as setting up DYLD libraries
    4242        args = ['open', '-a', app_path] + args
    43         cls._launch_process_with_caffinate(args)
     43        cls._launch_process_with_caffeinate(args)
    4444
    4545    @classmethod
     
    5858
    5959    @classmethod
    60     def _launch_process_with_caffinate(cls, args, env=None):
    61         process = subprocess.Popen(args, env=env)
     60    def _launch_process_with_caffeinate(cls, args, env=None):
     61        try:
     62            process = subprocess.Popen(args, env=env)
     63        except Exception as error:
     64            _log.error('Popen failed: {error}'.format(error=error))
     65            return
     66
    6267        subprocess.Popen(["/usr/bin/caffeinate", "-disw", str(process.pid)])
    6368        return process
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_chrome_driver.py

    • Property svn:executable set to *
    r224688 r239522  
    1515    app_name = 'Google Chrome.app'
    1616
    17     def launch_url(self, url, options, browser_build_path):
     17    def launch_url(self, url, options, browser_build_path, browser_path):
     18        # FIXME: handle self._browser_path.
    1819        args_with_url = self._insert_url(create_args(), 2, url)
    1920        self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
     
    3839    app_name = 'Google Chrome Canary.app'
    3940
    40     def launch_url(self, url, options, browser_build_path):
     41    def launch_url(self, url, options, browser_build_path, browser_path):
     42        # FIXME: handle self._browser_path.
    4143        args_with_url = self._insert_url(create_args(), 2, url)
    4244        self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_firefox_driver.py

    • Property svn:executable set to *
    r221655 r239522  
    1515    app_name = 'Firefox.app'
    1616
    17     def launch_url(self, url, options, browser_build_path):
     17    def launch_url(self, url, options, browser_build_path, browser_path):
     18        # FIXME: handle self._browser_path.
    1819        args_with_url = self._insert_url(create_args(), 0, url)
    1920        self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
     
    3940    app_name = 'FirefoxNightly.app'
    4041
    41     def launch_url(self, url, options, browser_build_path):
     42    def launch_url(self, url, options, browser_build_path, browser_path):
     43        # FIXME: handle self._browser_path.
    4244        args_with_url = self._insert_url(create_args(), 0, url)
    4345        self._launch_process(build_dir=browser_build_path, app_name=self.app_name, url=url, args=args_with_url)
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py

    • Property svn:executable set to *
    r223226 r239522  
    2525        self._safari_preferences = ["-HomePage", "about:blank", "-WarnAboutFraudulentWebsites", "0", "-ExtensionsEnabled", "0", "-ShowStatusBar", "0", "-NewWindowBehavior", "1", "-NewTabBehavior", "1"]
    2626
    27     def launch_url(self, url, options, browser_build_path):
     27    def launch_url(self, url, options, browser_build_path, browser_path):
    2828        args = ['/Applications/Safari.app/Contents/MacOS/Safari']
    2929        env = {}
     
    3535            else:
    3636                _log.info('Could not find Safari.app at %s, using the system Safari instead' % safari_app_in_build_path)
     37        elif browser_path:
     38            safari_app_in_browser_path = os.path.join(browser_path, 'Contents/MacOS/Safari')
     39            if os.path.exists(safari_app_in_browser_path):
     40                args = [safari_app_in_browser_path]
     41            else:
     42                _log.info('Could not find application at %s, using the system Safari instead' % safari_app_in_browser_path)
    3743
    3844        args.extend(self._safari_preferences)
    3945        _log.info('Launching safari: %s with url: %s' % (args[0], url))
    40         self._safari_process = OSXSafariDriver._launch_process_with_caffinate(args, env)
     46        self._safari_process = OSXSafariDriver._launch_process_with_caffeinate(args, env)
    4147
    4248        # Stop for initialization of the safari process, otherwise, open
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/run_benchmark.py

    r229946 r239522  
    4141    mutual_group.add_argument('--read-results-json', dest='json_file', help='Instead of running a benchmark, format the output saved in JSON_FILE.')
    4242    parser.add_argument('--output-file', default=None, help='Save detailed results to OUTPUT in JSON format. By default, results will not be saved.')
    43     parser.add_argument('--build-directory', dest='build_dir', help='Path to the browser executable (e.g. WebKitBuild/Release/).')
    4443    parser.add_argument('--count', type=int, help='Number of times to run the benchmark (e.g. 5).')
    4544    parser.add_argument('--driver', default=WebServerBenchmarkRunner.name, choices=benchmark_runner_subclasses.keys(), help='Use the specified benchmark driver. Defaults to %s.' % WebServerBenchmarkRunner.name)
     
    5150    parser.add_argument('--no-adjust-unit', dest='scale_unit', action='store_false', help="Don't convert to scientific notation.")
    5251    parser.add_argument('--show-iteration-values', dest='show_iteration_values', action='store_true', help="Show the measured value for each iteration in addition to averages.")
     52
     53    group = parser.add_mutually_exclusive_group()
     54    group.add_argument('--browser-path', help='Specify the path to a non-default copy of the target browser as a path to the .app.')
     55    group.add_argument('--build-directory', dest='build_dir', help='Path to the browser executable (e.g. WebKitBuild/Release/).')
    5356
    5457    args = parser.parse_args()
     
    6669def run_benchmark_plan(args, plan):
    6770    benchmark_runner_class = benchmark_runner_subclasses[args.driver]
    68     runner = benchmark_runner_class(plan, args.local_copy, args.count, args.build_dir, args.output_file, args.platform, args.browser, args.scale_unit, args.show_iteration_values, args.device_id)
     71    runner = benchmark_runner_class(plan, args.local_copy, args.count, args.build_dir, args.output_file, args.platform, args.browser, args.browser_path, args.scale_unit, args.show_iteration_values, args.device_id)
    6972    runner.execute()
    7073
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/webdriver_benchmark_runner.py

    • Property svn:executable set to *
    r221656 r239522  
    2323        try:
    2424            url = 'file://{root}/{plan_name}/{test_file}'.format(root=web_root, plan_name=self._plan_name, test_file=test_file)
    25             driver = self._browser_driver.launch_driver(url, self._plan['options'], self._build_dir)
     25            driver = self._browser_driver.launch_driver(url, self._plan['options'], self._build_dir, self._browser_path)
    2626            _log.info('Waiting on results from web browser')
    2727            result = WebDriverWait(driver, self._plan['timeout'], poll_frequency=1.0).until(self._get_result)
  • trunk/Tools/Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py

    • Property svn:executable set to *
    r227739 r239522  
    1616    name = 'webserver'
    1717
    18     def __init__(self, plan_file, local_copy, count_override, build_dir, output_file, platform, browser, scale_unit=True, show_iteration_values=False, device_id=None):
     18    def __init__(self, plan_file, local_copy, count_override, build_dir, output_file, platform, browser, browser_path, scale_unit=True, show_iteration_values=False, device_id=None):
    1919        self._http_server_driver = HTTPServerDriverFactory.create(platform)
    2020        self._http_server_driver.set_device_id(device_id)
    21         super(WebServerBenchmarkRunner, self).__init__(plan_file, local_copy, count_override, build_dir, output_file, platform, browser, scale_unit, show_iteration_values, device_id)
     21        super(WebServerBenchmarkRunner, self).__init__(plan_file, local_copy, count_override, build_dir, output_file, platform, browser, browser_path, scale_unit, show_iteration_values, device_id)
    2222
    2323    def _get_result(self, test_url):
     
    3131            self._http_server_driver.serve(web_root)
    3232            url = urlparse.urljoin(self._http_server_driver.base_url(), self._plan_name + '/' + test_file)
    33             self._browser_driver.launch_url(url, self._plan['options'], self._build_dir)
     33            self._browser_driver.launch_url(url, self._plan['options'], self._build_dir, self._browser_path)
    3434            with Timeout(self._plan['timeout']):
    3535                result = self._get_result(url)
  • trunk/Tools/Scripts/webkitpy/browserperfdash/browserperfdash_unittest.py

    • Property svn:executable set to *
    r232820 r239522  
    4141    name = 'fake'
    4242
    43     def __init__(self, plan_file, local_copy, count_override, build_dir, output_file, platform, browser):
    44         super(FakeBenchmarkRunner, self).__init__(plan_file, local_copy, count_override, build_dir, output_file, platform, browser)
     43    def __init__(self, plan_file, local_copy, count_override, build_dir, output_file, platform, browser, browser_path):
     44        super(FakeBenchmarkRunner, self).__init__(plan_file, local_copy, count_override, build_dir, output_file, platform, browser, browser_path)
    4545
    4646    def execute(self):
     
    6161        plan_list = BenchmarkRunner.available_plans()
    6262        build_dir = os.path.abspath(os.curdir)
    63         runner = FakeBenchmarkRunner(plan_list[0], False, 1, build_dir, "/tmp/testOutput.txt", default_platform(), default_browser())
     63        runner = FakeBenchmarkRunner(plan_list[0], False, 1, build_dir, "/tmp/testOutput.txt", default_platform(), default_browser(), None)
    6464        self.assertTrue(runner.execute())
Note: See TracChangeset for help on using the changeset viewer.