Commit 604751d0 authored by nednguyen's avatar nednguyen Committed by Commit bot

[Telemetry] Remove page_test.DidRunTest hook.

BUG=435757, 455391
CQ_EXTRA_TRYBOTS=tryserver.chromium.perf:linux_perf_bisect;tryserver.chromium.perf:mac_perf_bisect;tryserver.chromium.perf:android_nexus5_perf_bisect

Review URL: https://codereview.chromium.org/1142453002

Cr-Commit-Position: refs/heads/master@{#329862}
parent 793a471b
...@@ -39,8 +39,10 @@ SCORE_TRACE_NAME = 'score' ...@@ -39,8 +39,10 @@ SCORE_TRACE_NAME = 'score'
class _DomPerfMeasurement(page_test.PageTest): class _DomPerfMeasurement(page_test.PageTest):
def __init__(self): def __init__(self, expected_num_runs):
super(_DomPerfMeasurement, self).__init__() super(_DomPerfMeasurement, self).__init__()
self._expected_num_runs = expected_num_runs
self._runs_count = 0
def ValidateAndMeasurePage(self, page, tab, results): def ValidateAndMeasurePage(self, page, tab, results):
try: try:
...@@ -55,10 +57,15 @@ class _DomPerfMeasurement(page_test.PageTest): ...@@ -55,10 +57,15 @@ class _DomPerfMeasurement(page_test.PageTest):
results.AddValue(scalar.ScalarValue( results.AddValue(scalar.ScalarValue(
results.current_page, '%s.%s' % (suite['name'], SCORE_TRACE_NAME), results.current_page, '%s.%s' % (suite['name'], SCORE_TRACE_NAME),
SCORE_UNIT, suite['score'], important=False)) SCORE_UNIT, suite['score'], important=False))
finally: finally:
tab.EvaluateJavaScript('document.cookie = "__domperf_finished=0"') tab.EvaluateJavaScript('document.cookie = "__domperf_finished=0"')
self._runs_count += 1
# Only compute total metric when we reach the number of expected run.
if self._runs_count == self._expected_num_runs:
self._ComputeTotalMetric(results)
def DidRunTest(self, browser, results): def _ComputeTotalMetric(self, results):
# Now give the geometric mean as the total for the combined runs. # Now give the geometric mean as the total for the combined runs.
combined = merge_values.MergeLikeValuesFromDifferentPages( combined = merge_values.MergeLikeValuesFromDifferentPages(
results.all_page_specific_values, results.all_page_specific_values,
...@@ -77,28 +84,32 @@ class DomPerf(benchmark.Benchmark): ...@@ -77,28 +84,32 @@ class DomPerf(benchmark.Benchmark):
The final score is computed as the geometric mean of the individual results. The final score is computed as the geometric mean of the individual results.
Scores are not comparable across benchmark suite versions and higher scores Scores are not comparable across benchmark suite versions and higher scores
means better performance: Bigger is better!""" means better performance: Bigger is better!"""
test = _DomPerfMeasurement
RUN_PARAMS = [
'Accessors',
'CloneNodes',
'CreateNodes',
'DOMDivWalk',
'DOMTable',
'DOMWalk',
'Events',
'Get+Elements',
'GridSort',
'Template'
]
@classmethod @classmethod
def Name(cls): def Name(cls):
return 'dom_perf' return 'dom_perf'
def CreatePageTest(self, options):
del options
return _DomPerfMeasurement(len(self.RUN_PARAMS))
def CreatePageSet(self, options): def CreatePageSet(self, options):
dom_perf_dir = os.path.join(util.GetChromiumSrcDir(), 'data', 'dom_perf') dom_perf_dir = os.path.join(util.GetChromiumSrcDir(), 'data', 'dom_perf')
run_params = [
'Accessors',
'CloneNodes',
'CreateNodes',
'DOMDivWalk',
'DOMTable',
'DOMWalk',
'Events',
'Get+Elements',
'GridSort',
'Template'
]
ps = page_set.PageSet(file_path=dom_perf_dir) ps = page_set.PageSet(file_path=dom_perf_dir)
for param in run_params: for param in self.RUN_PARAMS:
ps.AddUserStory(page_module.Page( ps.AddUserStory(page_module.Page(
'file://run.html?reportInJS=1&run=%s' % param, ps, ps.base_dir)) 'file://run.html?reportInJS=1&run=%s' % param, ps, ps.base_dir))
return ps return ps
...@@ -364,33 +364,31 @@ class StoryRunnerTest(unittest.TestCase): ...@@ -364,33 +364,31 @@ class StoryRunnerTest(unittest.TestCase):
self.SuppressExceptionFormatting() self.SuppressExceptionFormatting()
us = user_story_set.UserStorySet() us = user_story_set.UserStorySet()
unit_test_events = [] # track what was called when
class DidRunTestError(Exception): class DidRunTestError(Exception):
pass pass
class TestTearDownSharedState(TestSharedPageState): class TestTearDownSharedState(TestSharedPageState):
def TearDownState(self, results): def TearDownState(self, results):
self._test.DidRunTest('app', results) unit_test_events.append('tear-down-state')
raise DidRunTestError
class Test(page_test.PageTest): class Test(page_test.PageTest):
def __init__(self, *args): def __init__(self, *args):
super(Test, self).__init__(*args) super(Test, self).__init__(*args)
self.run_count = 0 self.run_count = 0
self._unit_test_events = [] # track what was called when
def RunPage(self, *_): def RunPage(self, *_):
old_run_count = self.run_count old_run_count = self.run_count
self.run_count += 1 self.run_count += 1
if old_run_count == 0: if old_run_count == 0:
self._unit_test_events.append('app-crash') unit_test_events.append('app-crash')
raise exceptions.AppCrashException raise exceptions.AppCrashException
def ValidateAndMeasurePage(self, page, tab, results): def ValidateAndMeasurePage(self, page, tab, results):
pass pass
def DidRunTest(self, _, __):
self._unit_test_events.append('did-run-test')
raise DidRunTestError
us.AddUserStory(DummyLocalUserStory(TestTearDownSharedState)) us.AddUserStory(DummyLocalUserStory(TestTearDownSharedState))
us.AddUserStory(DummyLocalUserStory(TestTearDownSharedState)) us.AddUserStory(DummyLocalUserStory(TestTearDownSharedState))
test = Test() test = Test()
...@@ -398,7 +396,7 @@ class StoryRunnerTest(unittest.TestCase): ...@@ -398,7 +396,7 @@ class StoryRunnerTest(unittest.TestCase):
with self.assertRaises(DidRunTestError): with self.assertRaises(DidRunTestError):
story_runner.Run( story_runner.Run(
test, us, self.expectations, self.options, self.results) test, us, self.expectations, self.options, self.results)
self.assertEqual(['app-crash', 'did-run-test'], test._unit_test_events) self.assertEqual(['app-crash', 'tear-down-state'], unit_test_events)
# The AppCrashException gets added as a failure. # The AppCrashException gets added as a failure.
self.assertEquals(1, len(self.results.failures)) self.assertEquals(1, len(self.results.failures))
......
...@@ -142,13 +142,6 @@ class PageTest(object): ...@@ -142,13 +142,6 @@ class PageTest(object):
"""Sets the BrowserFinderOptions instance to use.""" """Sets the BrowserFinderOptions instance to use."""
self.options = options self.options = options
def DidRunTest(self, browser, results): # pylint: disable=W0613
"""Override to do operations after all page set(s) are completed.
This will occur before the browser is torn down.
"""
self.options = None
def WillNavigateToPage(self, page, tab): def WillNavigateToPage(self, page, tab):
"""Override to do operations before the page is navigated, notably Telemetry """Override to do operations before the page is navigated, notably Telemetry
will already have performed the following operations on the browser before will already have performed the following operations on the browser before
......
...@@ -268,10 +268,6 @@ class SharedPageState(shared_state.SharedState): ...@@ -268,10 +268,6 @@ class SharedPageState(shared_state.SharedState):
raise raise
def TearDownState(self, results): def TearDownState(self, results):
# NOTE: this is a HACK to get story_runner to be generic enough for any
# user_story while maintaining existing use cases of page tests. Other
# SharedUserStory should not call DidRunTest this way.
self._test.DidRunTest(self.browser, results)
self._StopBrowser() self._StopBrowser()
def _StopBrowser(self): def _StopBrowser(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment