Commit aa52489e authored by skyostil@chromium.org's avatar skyostil@chromium.org

telemetry: Use trace categories to configure synthetic delays

BUG=307841
TEST=tools/perf/run_benchmark scheduler.tough_scheduling_cases

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243993 0039d316-1c4b-4281-b951-d872f2087c98
parent 234ceced
# 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 import test
from measurements import smoothness
class SchedulerToughSchedulingCases(test.Test):
"""Measures rendering statistics while interacting with pages that have
challenging scheduling properties.
https://docs.google.com/a/chromium.org/document/d/
17yhE5Po9By0sCdM1yZT3LiUECaUr_94rQt9j-4tOQIM/view"""
test = smoothness.Smoothness
page_set = 'page_sets/tough_scheduling_cases.json'
......@@ -29,13 +29,3 @@ class SmoothnessKeyMobileSites(test.Test):
http://www.chromium.org/developers/design-documents/rendering-benchmarks"""
test = smoothness.Smoothness
page_set = 'page_sets/key_mobile_sites.json'
class SmoothnessToughSchedulingCases(test.Test):
"""Measures rendering statistics while interacting with pages that have
challenging scheduling properties.
https://docs.google.com/a/chromium.org/document/d/
17yhE5Po9By0sCdM1yZT3LiUECaUr_94rQt9j-4tOQIM/view"""
test = smoothness.Smoothness
page_set = 'page_sets/tough_scheduling_cases.json'
......@@ -27,6 +27,17 @@ class NoSupportedActionError(page_measurement.MeasurementFailure):
'None of the actions is supported by smoothness measurement')
def _GetSyntheticDelayCategoriesFromPage(page):
if not hasattr(page, 'synthetic_delays'):
return []
result = []
for delay, options in page.synthetic_delays.items():
options = '%f;%s' % (options.get('target_duration', 0),
options.get('mode', 'static'))
result.append('DELAY(%s;%s)' % (delay, options))
return result
class SmoothnessMetric(Metric):
def __init__(self):
super(SmoothnessMetric, self).__init__()
......@@ -37,7 +48,9 @@ class SmoothnessMetric(Metric):
self._actions.append(action)
def Start(self, page, tab):
tab.browser.StartTracing('webkit.console,benchmark', 60)
custom_categories = ['webkit.console', 'benchmark']
custom_categories += _GetSyntheticDelayCategoriesFromPage(page)
tab.browser.StartTracing(','.join(custom_categories), 60)
tab.ExecuteJavaScript('console.time("' + TIMELINE_MARKER + '")')
if tab.browser.platform.IsRawDisplayFrameRateSupported():
tab.browser.platform.StartRawDisplayFrameRateMeasurement()
......
# 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.
import unittest
from metrics import smoothness
from telemetry.page import page
class FakePlatform(object):
def IsRawDisplayFrameRateSupported(self):
return False
class FakeBrowser(object):
def __init__(self):
self.platform = FakePlatform()
self.category_filter = None
def StartTracing(self, category_filter, _):
self.category_filter = category_filter
class FakeTab(object):
def __init__(self):
self.browser = FakeBrowser()
def ExecuteJavaScript(self, js):
pass
class SmoothnessMetricUnitTest(unittest.TestCase):
def testSyntheticDelayConfiguration(self):
attributes = {
'synthetic_delays': {
'cc.BeginMainFrame': { 'target_duration': 0.012 },
'cc.DrawAndSwap': { 'target_duration': 0.012, 'mode': 'alternating' },
'gpu.SwapBuffers': { 'target_duration': 0.012 }
}
}
test_page = page.Page('http://dummy', None, attributes=attributes)
tab = FakeTab()
smoothness_metric = smoothness.SmoothnessMetric()
smoothness_metric.Start(test_page, tab)
expected_category_filter = [
'DELAY(cc.BeginMainFrame;0.012000;static)',
'DELAY(cc.DrawAndSwap;0.012000;alternating)',
'DELAY(gpu.SwapBuffers;0.012000;static)',
'benchmark',
'webkit.console'
]
self.assertEquals(expected_category_filter,
sorted(tab.browser.category_filter.split(',')))
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