Commit fbd94721 authored by nednguyen's avatar nednguyen Committed by Commit bot

Move all the page actions from repaint measurements to repaint pages.

This is due to 2 reasons:
+ Page specific logic should belong to page, not page test.
+ Simplify the repaint measurement control code, which make
it easier to port repaint to TimelineBasedMeasurement.

Trybot link for repaint.gpu_rasterization.key_mobile_sites_repaint:
https://codereview.chromium.org/1098543002

BUG=444703, 455391

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

Cr-Commit-Position: refs/heads/master@{#325558}
parent b51933da
...@@ -27,16 +27,18 @@ class _Repaint(benchmark.Benchmark): ...@@ -27,16 +27,18 @@ class _Repaint(benchmark.Benchmark):
def Name(cls): def Name(cls):
return 'repaint' return 'repaint'
def CreateUserStorySet(self, options):
return page_sets.KeyMobileSitesRepaintPageSet(
options.mode, options.width, options.height)
def CreatePageTest(self, options): def CreatePageTest(self, options):
return repaint_measurement.Repaint(options.mode, options.width, return repaint_measurement.Repaint()
options.height)
@benchmark.Enabled('android') @benchmark.Enabled('android')
class RepaintKeyMobileSites(_Repaint): class RepaintKeyMobileSites(_Repaint):
"""Measures repaint performance on the key mobile sites. """Measures repaint performance on the key mobile sites.
http://www.chromium.org/developers/design-documents/rendering-benchmarks""" http://www.chromium.org/developers/design-documents/rendering-benchmarks"""
page_set = page_sets.KeyMobileSitesRepaintPageSet
@classmethod @classmethod
def Name(cls): def Name(cls):
...@@ -50,9 +52,9 @@ class RepaintGpuRasterizationKeyMobileSites(_Repaint): ...@@ -50,9 +52,9 @@ class RepaintGpuRasterizationKeyMobileSites(_Repaint):
http://www.chromium.org/developers/design-documents/rendering-benchmarks""" http://www.chromium.org/developers/design-documents/rendering-benchmarks"""
tag = 'gpu_rasterization' tag = 'gpu_rasterization'
page_set = page_sets.KeyMobileSitesRepaintPageSet
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
silk_flags.CustomizeBrowserOptionsForGpuRasterization(options) silk_flags.CustomizeBrowserOptionsForGpuRasterization(options)
@classmethod @classmethod
def Name(cls): def Name(cls):
return 'repaint.gpu_rasterization.key_mobile_sites_repaint' return 'repaint.gpu_rasterization.key_mobile_sites_repaint'
......
...@@ -8,13 +8,9 @@ from measurements import smoothness_controller ...@@ -8,13 +8,9 @@ from measurements import smoothness_controller
class Repaint(page_test.PageTest): class Repaint(page_test.PageTest):
def __init__(self, mode='viewport', width=None, height=None): def __init__(self):
super(Repaint, self).__init__() super(Repaint, self).__init__()
self._smoothness_controller = None self._smoothness_controller = None
self._micro_benchmark_id = None
self._mode = mode
self._width = width
self._height = height
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
options.AppendExtraBrowserArgs([ options.AppendExtraBrowserArgs([
...@@ -29,42 +25,8 @@ class Repaint(page_test.PageTest): ...@@ -29,42 +25,8 @@ class Repaint(page_test.PageTest):
auto_issuing_marker=False) auto_issuing_marker=False)
self._smoothness_controller.SetUp(page, tab) self._smoothness_controller.SetUp(page, tab)
self._smoothness_controller.Start(tab) self._smoothness_controller.Start(tab)
# Rasterize only what's visible.
tab.ExecuteJavaScript(
'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();')
args = {}
args['mode'] = self._mode
if self._width:
args['width'] = self._width
if self._height:
args['height'] = self._height
# Enque benchmark
tab.ExecuteJavaScript("""
window.benchmark_results = {};
window.benchmark_results.id =
chrome.gpuBenchmarking.runMicroBenchmark(
"invalidation_benchmark",
function(value) {},
""" + str(args) + """
);
""")
self._micro_benchmark_id = tab.EvaluateJavaScript(
'window.benchmark_results.id')
if (not self._micro_benchmark_id):
raise page_test.MeasurementFailure(
'Failed to schedule invalidation_benchmark.')
def DidRunActions(self, page, tab): def DidRunActions(self, page, tab):
tab.ExecuteJavaScript("""
window.benchmark_results.message_handled =
chrome.gpuBenchmarking.sendMessageToMicroBenchmark(
""" + str(self._micro_benchmark_id) + """, {
"notify_done": true
});
""")
self._smoothness_controller.Stop(tab) self._smoothness_controller.Stop(tab)
def ValidateAndMeasurePage(self, page, tab, results): def ValidateAndMeasurePage(self, page, tab, results):
......
...@@ -9,6 +9,7 @@ from telemetry.unittest_util import options_for_unittests ...@@ -9,6 +9,7 @@ from telemetry.unittest_util import options_for_unittests
from telemetry.unittest_util import page_test_test_case from telemetry.unittest_util import page_test_test_case
from measurements import repaint from measurements import repaint
from page_sets import repaint_helpers
class TestRepaintPage(page_module.Page): class TestRepaintPage(page_module.Page):
...@@ -17,8 +18,7 @@ class TestRepaintPage(page_module.Page): ...@@ -17,8 +18,7 @@ class TestRepaintPage(page_module.Page):
page_set, base_dir) page_set, base_dir)
def RunPageInteractions(self, action_runner): def RunPageInteractions(self, action_runner):
with action_runner.CreateInteraction('Repaint'): repaint_helpers.Repaint(action_runner)
action_runner.RepaintContinuously(seconds=2)
class RepaintUnitTest(page_test_test_case.PageTestTestCase): class RepaintUnitTest(page_test_test_case.PageTestTestCase):
......
...@@ -5,39 +5,42 @@ from telemetry.page import page as page_module ...@@ -5,39 +5,42 @@ from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module from telemetry.page import page_set as page_set_module
from page_sets import key_mobile_sites_pages from page_sets import key_mobile_sites_pages
from page_sets import repaint_helpers
def _RepaintContinously(action_runner):
with action_runner.CreateInteraction('Repaint'):
action_runner.RepaintContinuously(seconds=5)
def _CreatePageClassWithRepaintInteractions(page_cls, mode, height, width):
def _CreatePageClassWithRepaintInteractions(page_cls):
class DerivedRepaintPage(page_cls): # pylint: disable=W0232 class DerivedRepaintPage(page_cls): # pylint: disable=W0232
def RunPageInteractions(self, action_runner): def RunPageInteractions(self, action_runner):
_RepaintContinously(action_runner) repaint_helpers.Repaint(
action_runner, mode=mode, width=width, height=height)
return DerivedRepaintPage return DerivedRepaintPage
class KeyMobileSitesRepaintPage(page_module.Page): class KeyMobileSitesRepaintPage(page_module.Page):
def __init__(self, url, page_set, name='', labels=None): def __init__(self, url, page_set, mode, height, width, name='', labels=None):
super(KeyMobileSitesRepaintPage, self).__init__( super(KeyMobileSitesRepaintPage, self).__init__(
url=url, page_set=page_set, name=name, url=url, page_set=page_set, name=name,
credentials_path='data/credentials.json', labels=labels) credentials_path='data/credentials.json', labels=labels)
self.user_agent_type = 'mobile' self.user_agent_type = 'mobile'
self.archive_data_file = 'data/key_mobile_sites_repaint.json' self.archive_data_file = 'data/key_mobile_sites_repaint.json'
self._mode = mode
self._width = width
self._height = height
def RunPageInteractions(self, action_runner): def RunPageInteractions(self, action_runner):
_RepaintContinously(action_runner) repaint_helpers.Repaint(
action_runner, mode=self._mode, width=self._width, height=self._height)
class KeyMobileSitesRepaintPageSet(page_set_module.PageSet): class KeyMobileSitesRepaintPageSet(page_set_module.PageSet):
""" Key mobile sites with repaint interactions. """ """ Key mobile sites with repaint interactions. """
def __init__(self): def __init__(self, mode='viewport', width=None, height=None):
super(KeyMobileSitesRepaintPageSet, self).__init__( super(KeyMobileSitesRepaintPageSet, self).__init__(
user_agent_type='mobile', user_agent_type='mobile',
archive_data_file='data/key_mobile_sites_repaint.json', archive_data_file='data/key_mobile_sites_repaint.json',
...@@ -66,37 +69,39 @@ class KeyMobileSitesRepaintPageSet(page_set_module.PageSet): ...@@ -66,37 +69,39 @@ class KeyMobileSitesRepaintPageSet(page_set_module.PageSet):
] ]
for page_class in predefined_page_classes: for page_class in predefined_page_classes:
self.AddUserStory( self.AddUserStory(
_CreatePageClassWithRepaintInteractions(page_class)(self)) _CreatePageClassWithRepaintInteractions(
page_class, mode=mode, height=height, width=width)(self))
# Add pages with custom labels. # Add pages with custom labels.
# Why: Top news site. # Why: Top news site.
self.AddUserStory(KeyMobileSitesRepaintPage( self.AddUserStory(KeyMobileSitesRepaintPage(
url='http://nytimes.com/', page_set=self, labels=['fastpath'])) url='http://nytimes.com/', page_set=self, labels=['fastpath'],
mode=mode, height=height, width=width))
# Why: Image-heavy site. # Why: Image-heavy site.
self.AddUserStory(KeyMobileSitesRepaintPage( self.AddUserStory(KeyMobileSitesRepaintPage(
url='http://cuteoverload.com', page_set=self, labels=['fastpath'])) url='http://cuteoverload.com', page_set=self, labels=['fastpath'],
mode=mode, height=height, width=width))
# Why: #11 (Alexa global), google property; some blogger layouts # Why: #11 (Alexa global), google property; some blogger layouts
# have infinite scroll but more interesting. # have infinite scroll but more interesting.
self.AddUserStory(KeyMobileSitesRepaintPage( self.AddUserStory(KeyMobileSitesRepaintPage(
url='http://googlewebmastercentral.blogspot.com/', url='http://googlewebmastercentral.blogspot.com/',
page_set=self, name='Blogger')) page_set=self, name='Blogger', mode=mode, height=height, width=width))
# Why: #18 (Alexa global), Picked an interesting post """ # Why: #18 (Alexa global), Picked an interesting post """
self.AddUserStory(KeyMobileSitesRepaintPage( self.AddUserStory(KeyMobileSitesRepaintPage(
# pylint: disable=line-too-long # pylint: disable=line-too-long
url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/', url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
page_set=self, page_set=self,
name='Wordpress')) name='Wordpress', mode=mode, height=height, width=width))
# Why: #6 (Alexa) most visited worldwide, picked an interesting page # Why: #6 (Alexa) most visited worldwide, picked an interesting page
self.AddUserStory(KeyMobileSitesRepaintPage( self.AddUserStory(KeyMobileSitesRepaintPage(
url='http://en.wikipedia.org/wiki/Wikipedia', url='http://en.wikipedia.org/wiki/Wikipedia',
page_set=self, page_set=self,
name='Wikipedia (1 tab)')) name='Wikipedia (1 tab)', mode=mode, height=height, width=width))
# Why: #8 (Alexa global), picked an interesting page # Why: #8 (Alexa global), picked an interesting page
# Forbidden (Rate Limit Exceeded) # Forbidden (Rate Limit Exceeded)
...@@ -107,7 +112,7 @@ class KeyMobileSitesRepaintPageSet(page_set_module.PageSet): ...@@ -107,7 +112,7 @@ class KeyMobileSitesRepaintPageSet(page_set_module.PageSet):
self.AddUserStory(KeyMobileSitesRepaintPage( self.AddUserStory(KeyMobileSitesRepaintPage(
url='http://pinterest.com', url='http://pinterest.com',
page_set=self, page_set=self,
name='Pinterest')) name='Pinterest', mode=mode, height=height, width=width))
# Why: #1 sports. # Why: #1 sports.
# Fails often; crbug.com/249722' # Fails often; crbug.com/249722'
...@@ -119,17 +124,20 @@ class KeyMobileSitesRepaintPageSet(page_set_module.PageSet): ...@@ -119,17 +124,20 @@ class KeyMobileSitesRepaintPageSet(page_set_module.PageSet):
# url='http://forecast.io', page_set=self)) # url='http://forecast.io', page_set=self))
# Why: crbug.com/169827 # Why: crbug.com/169827
self.AddUserStory(KeyMobileSitesRepaintPage( self.AddUserStory(KeyMobileSitesRepaintPage(
url='http://slashdot.org/', page_set=self, labels=['fastpath'])) url='http://slashdot.org/', page_set=self, labels=['fastpath'],
mode=mode, width=width, height=height))
# Why: #5 Alexa news """ # Why: #5 Alexa news """
self.AddUserStory(KeyMobileSitesRepaintPage( self.AddUserStory(KeyMobileSitesRepaintPage(
url='http://www.reddit.com/r/programming/comments/1g96ve', url='http://www.reddit.com/r/programming/comments/1g96ve',
page_set=self, labels=['fastpath'])) page_set=self, labels=['fastpath'],
mode=mode, width=width, height=height))
# Why: Problematic use of fixed position elements """ # Why: Problematic use of fixed position elements """
self.AddUserStory(KeyMobileSitesRepaintPage( self.AddUserStory(KeyMobileSitesRepaintPage(
url='http://www.boingboing.net', page_set=self, labels=['fastpath'])) url='http://www.boingboing.net', page_set=self, labels=['fastpath'],
mode=mode, width=width, height=height))
# Add simple pages with no custom navigation logic or labels. # Add simple pages with no custom navigation logic or labels.
urls_list = [ urls_list = [
...@@ -183,4 +191,5 @@ class KeyMobileSitesRepaintPageSet(page_set_module.PageSet): ...@@ -183,4 +191,5 @@ class KeyMobileSitesRepaintPageSet(page_set_module.PageSet):
] ]
for url in urls_list: for url in urls_list:
self.AddUserStory(KeyMobileSitesRepaintPage(url, self)) self.AddUserStory(KeyMobileSitesRepaintPage(
url, self, mode=mode, height=height, width=width))
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import page_test
def Repaint(action_runner, mode='viewport', width=None, height=None):
# Rasterize only what's visible.
action_runner.ExecuteJavaScript(
'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();')
args = {}
args['mode'] = mode
if width:
args['width'] = width
if height:
args['height'] = height
# Enque benchmark
action_runner.ExecuteJavaScript("""
window.benchmark_results = {};
window.benchmark_results.id =
chrome.gpuBenchmarking.runMicroBenchmark(
"invalidation_benchmark",
function(value) {},
""" + str(args) + """
);
""")
micro_benchmark_id = action_runner.EvaluateJavaScript(
'window.benchmark_results.id')
if (not micro_benchmark_id):
raise page_test.MeasurementFailure(
'Failed to schedule invalidation_benchmark.')
with action_runner.CreateInteraction('Repaint'):
action_runner.RepaintContinuously(seconds=5)
action_runner.ExecuteJavaScript("""
window.benchmark_results.message_handled =
chrome.gpuBenchmarking.sendMessageToMicroBenchmark(
""" + str(micro_benchmark_id) + """, {
"notify_done": true
});
""")
...@@ -5,27 +5,35 @@ from telemetry.page import page as page_module ...@@ -5,27 +5,35 @@ from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module from telemetry.page import page_set as page_set_module
from page_sets import top_pages from page_sets import top_pages
from page_sets import repaint_helpers
class TopRepaintPage(page_module.Page): class TopRepaintPage(page_module.Page):
def __init__(self, url, page_set, name='', credentials=None): def __init__(self, url, page_set, mode, width, height, name='',
credentials=None):
super(TopRepaintPage, self).__init__( super(TopRepaintPage, self).__init__(
url=url, page_set=page_set, name=name, url=url, page_set=page_set, name=name,
credentials_path='data/credentials.json') credentials_path='data/credentials.json')
self.user_agent_type = 'desktop' self.user_agent_type = 'desktop'
self.archive_data_file = 'data/top_25_repaint.json' self.archive_data_file = 'data/top_25_repaint.json'
self.credentials = credentials self.credentials = credentials
self._mode = mode
self._width = width
self._height = height
def RunPageInteractions(self, action_runner): def RunPageInteractions(self, action_runner):
action_runner.RepaintContinuously(seconds=5) repaint_helpers.Repaint(
action_runner, mode=self._mode, width=self._width, height=self._height)
def _CreatePageClassWithRepaintInteractions(page_cls): def _CreatePageClassWithRepaintInteractions(page_cls, mode, width, height):
class DerivedRepaintPage(page_cls): # pylint: disable=W0232 class DerivedRepaintPage(page_cls): # pylint: disable=W0232
def RunPageInteractions(self, action_runner): def RunPageInteractions(self, action_runner):
action_runner.RepaintContinuously(seconds=5) repaint_helpers.Repaint(
action_runner, mode=mode, width=width, height=height)
return DerivedRepaintPage return DerivedRepaintPage
...@@ -33,7 +41,7 @@ class Top25RepaintPageSet(page_set_module.PageSet): ...@@ -33,7 +41,7 @@ class Top25RepaintPageSet(page_set_module.PageSet):
""" Pages hand-picked for 2012 CrOS scrolling tuning efforts. """ """ Pages hand-picked for 2012 CrOS scrolling tuning efforts. """
def __init__(self): def __init__(self, mode='viewport', width=None, height=None):
super(Top25RepaintPageSet, self).__init__( super(Top25RepaintPageSet, self).__init__(
user_agent_type='desktop', user_agent_type='desktop',
archive_data_file='data/top_25_repaint.json', archive_data_file='data/top_25_repaint.json',
...@@ -60,7 +68,8 @@ class Top25RepaintPageSet(page_set_module.PageSet): ...@@ -60,7 +68,8 @@ class Top25RepaintPageSet(page_set_module.PageSet):
] ]
for cl in top_page_classes: for cl in top_page_classes:
self.AddUserStory(_CreatePageClassWithRepaintInteractions(cl)(self)) self.AddUserStory(_CreatePageClassWithRepaintInteractions(
cl, mode=mode, width=width, height=height)(self))
other_urls = [ other_urls = [
# Why: #1 news worldwide (Alexa global) # Why: #1 news worldwide (Alexa global)
...@@ -83,4 +92,5 @@ class Top25RepaintPageSet(page_set_module.PageSet): ...@@ -83,4 +92,5 @@ class Top25RepaintPageSet(page_set_module.PageSet):
] ]
for url in other_urls: for url in other_urls:
self.AddUserStory(TopRepaintPage(url, self)) self.AddUserStory(
TopRepaintPage(url, self, mode=mode, height=height, width=width))
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