Skip to content
Permalink
Browse files
run-benchmarks should have an intial prep and restore env call for ta…
…sks that are too expensive to do for every iteration

https://bugs.webkit.org/show_bug.cgi?id=197339

Reviewed by Dewei Zhu.

Add two new functions prepare_inital_env and restore_env_after_all_testing around the entire
test run for setup steps that are too expensive to do every iteration.

* Scripts/webkitpy/benchmark_runner/benchmark_runner.py:
(BenchmarkRunner._run_benchmark):
* Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver.py:
(BrowserDriver):
(BrowserDriver.prepare_initial_env):
(BrowserDriver.restore_env_after_all_testing):
* Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py:
(LinuxBrowserDriver.prepare_initial_env):
(LinuxBrowserDriver.restore_env_after_all_testing):
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:
(OSXBrowserDriver.prepare_initial_env):
(OSXBrowserDriver.restore_env_after_all_testing):

Canonical link: https://commits.webkit.org/211562@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244730 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
sundiamonde committed Apr 29, 2019
1 parent 43c7986 commit 4788e60a14307af4650a1b5c10a14dcaf0f14f15
Showing 5 changed files with 72 additions and 25 deletions.
@@ -1,3 +1,26 @@
2019-04-26 Stephanie Lewis <slewis@apple.com>

run-benchmarks should have an intial prep and restore env call for tasks that are too expensive to do for every iteration
https://bugs.webkit.org/show_bug.cgi?id=197339

Reviewed by Dewei Zhu.

Add two new functions prepare_inital_env and restore_env_after_all_testing around the entire
test run for setup steps that are too expensive to do every iteration.

* Scripts/webkitpy/benchmark_runner/benchmark_runner.py:
(BenchmarkRunner._run_benchmark):
* Scripts/webkitpy/benchmark_runner/browser_driver/browser_driver.py:
(BrowserDriver):
(BrowserDriver.prepare_initial_env):
(BrowserDriver.restore_env_after_all_testing):
* Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py:
(LinuxBrowserDriver.prepare_initial_env):
(LinuxBrowserDriver.restore_env_after_all_testing):
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_browser_driver.py:
(OSXBrowserDriver.prepare_initial_env):
(OSXBrowserDriver.restore_env_after_all_testing):

2019-04-28 Andy Estes <aestes@apple.com>

Fix the watchOS engineering build.
@@ -77,32 +77,36 @@ def _run_one_test(self, web_root, test_file):
def _run_benchmark(self, count, web_root):
results = []
debug_outputs = []
for iteration in xrange(1, count + 1):
_log.info('Start the iteration {current_iteration} of {iterations} for current benchmark'.format(current_iteration=iteration, iterations=count))
try:
self._browser_driver.prepare_env(self._config)

if 'entry_point' in self._plan:
result = self._run_one_test(web_root, self._plan['entry_point'])
debug_outputs.append(result.pop('debugOutput', None))
assert(result)
results.append(result)
elif 'test_files' in self._plan:
run_result = {}
for test in self._plan['test_files']:
result = self._run_one_test(web_root, test)
assert(result)
run_result = self._merge(run_result, result)
try:
self._browser_driver.prepare_initial_env(self._config)
for iteration in xrange(1, count + 1):
_log.info('Start the iteration {current_iteration} of {iterations} for current benchmark'.format(current_iteration=iteration, iterations=count))
try:
self._browser_driver.prepare_env(self._config)

if 'entry_point' in self._plan:
result = self._run_one_test(web_root, self._plan['entry_point'])
debug_outputs.append(result.pop('debugOutput', None))

results.append(run_result)
else:
raise Exception('Plan does not contain entry_point or test_files')

finally:
self._browser_driver.restore_env()

_log.info('End the iteration {current_iteration} of {iterations} for current benchmark'.format(current_iteration=iteration, iterations=count))
assert(result)
results.append(result)
elif 'test_files' in self._plan:
run_result = {}
for test in self._plan['test_files']:
result = self._run_one_test(web_root, test)
assert(result)
run_result = self._merge(run_result, result)
debug_outputs.append(result.pop('debugOutput', None))

results.append(run_result)
else:
raise Exception('Plan does not contain entry_point or test_files')

finally:
self._browser_driver.restore_env()

_log.info('End the iteration {current_iteration} of {iterations} for current benchmark'.format(current_iteration=iteration, iterations=count))
finally:
self._browser_driver.restore_env_after_all_testing()

results = self._wrap(results)
output_file = self._output_file if self._output_file else self._plan['output_file']
@@ -14,6 +14,10 @@ class BrowserDriver(object):
def prepare_env(self, config):
pass

@abstractmethod
def prepare_initial_env(self, config):
pass

@abstractmethod
def launch_url(self, url, options, browser_build_path=None, browser_path=None):
pass
@@ -34,6 +38,10 @@ def close_browsers(self):
def restore_env(self):
pass

@abstractmethod
def restore_env_after_all_testing(self):
pass

@property
def webdriver_binary_path(self):
return get_driver_binary_path(self.browser_name)
@@ -58,9 +58,15 @@ def prepare_env(self, config):
self._test_environ = dict(os.environ)
self._test_environ['HOME'] = self._temp_profiledir

def prepare_initial_env(self, config):
pass

def restore_env(self):
force_remove(self._temp_profiledir)

def restore_env_after_all_testing(self):
pass

def close_browsers(self):
if self._browser_process:
if self._browser_process.poll() is None: # still running
@@ -16,6 +16,9 @@ class OSXBrowserDriver(BrowserDriver):
platform = 'osx'
bundle_id = None

def prepare_initial_env(self, config):
pass

def prepare_env(self, config):
self.close_browsers()
from Quartz import CGWarpMouseCursorPosition
@@ -29,6 +32,9 @@ def restore_env(self):
write_defaults('com.apple.dock', 'launchanim', True)
self._terminate_processes('Dock', 'com.apple.dock')

def restore_env_after_all_testing(self):
pass

def close_browsers(self):
self._terminate_processes(self.process_name, self.bundle_id)

0 comments on commit 4788e60

Please sign in to comment.