Commit 05a526aa authored by jeremy@chromium.org's avatar jeremy@chromium.org

[Telemetry] Measure power in tab_switching measurement

* Measure power instead of CPU usage in tab switching measurement.
* Fix a bug in said measurement where the initial open tab in the browser window was not navigated.
* Add a benchmark that switches between 5 blank tabs.

BUG=339180

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255925 0039d316-1c4b-4281-b951-d872f2087c98
parent 8a3867fa
...@@ -10,3 +10,8 @@ from measurements import tab_switching ...@@ -10,3 +10,8 @@ from measurements import tab_switching
class TabSwitchingTop10(test.Test): class TabSwitchingTop10(test.Test):
test = tab_switching.TabSwitching test = tab_switching.TabSwitching
page_set = 'page_sets/top_10.json' page_set = 'page_sets/top_10.json'
class TabSwitchingFiveBlankTabs(test.Test):
test = tab_switching.TabSwitching
page_set = 'page_sets/five_blank_pages.json'
options = {'pageset_repeat_iters': 10}
...@@ -7,12 +7,13 @@ ...@@ -7,12 +7,13 @@
This measurement opens pages in different tabs. After all the tabs have opened, This measurement opens pages in different tabs. After all the tabs have opened,
it cycles through each tab in sequence, and records a histogram of the time it cycles through each tab in sequence, and records a histogram of the time
between when a tab was first requested to be shown, and when it was painted. between when a tab was first requested to be shown, and when it was painted.
Power usage is also measured.
""" """
import time import time
from metrics import cpu
from metrics import histogram_util from metrics import histogram_util
from metrics import power
from telemetry.core import util from telemetry.core import util
from telemetry.page import page_measurement from telemetry.page import page_measurement
...@@ -21,30 +22,44 @@ from telemetry.page import page_measurement ...@@ -21,30 +22,44 @@ from telemetry.page import page_measurement
class TabSwitching(page_measurement.PageMeasurement): class TabSwitching(page_measurement.PageMeasurement):
def __init__(self): def __init__(self):
super(TabSwitching, self).__init__() super(TabSwitching, self).__init__()
self._cpu_metric = None self._first_page_in_pageset = True
self._power_metric = power.PowerMetric()
def CustomizeBrowserOptions(self, options): def CustomizeBrowserOptions(self, options):
options.AppendExtraBrowserArgs([ options.AppendExtraBrowserArgs([
'--enable-stats-collection-bindings' '--enable-stats-collection-bindings'
]) ])
power.PowerMetric.CustomizeBrowserOptions(options)
def DidStartBrowser(self, browser):
self._first_page_in_pageset = True
def TabForPage(self, page, browser): def TabForPage(self, page, browser):
if self._first_page_in_pageset:
# The initial browser window contains a single tab, navigate that tab
# rather than creating a new one.
self._first_page_in_pageset = False
return browser.tabs[0]
return browser.tabs.New() return browser.tabs.New()
def DidStartBrowser(self, browser): def StopBrowserAfterPage(self, browser, page):
self._cpu_metric = cpu.CpuMetric(browser) # Restart the browser after the last page in the pageset.
return len(browser.tabs) >= len(page.page_set.pages)
def MeasurePage(self, page, tab, results): def MeasurePage(self, page, tab, results):
"""On the last tab, cycle through each tab that was opened and then record """On the last tab, cycle through each tab that was opened and then record
a single histogram for the tab switching metric.""" a single histogram for the tab switching metric."""
if len(tab.browser.tabs) != len(page.page_set.pages): if len(tab.browser.tabs) != len(page.page_set.pages):
return return
self._cpu_metric.Start(page, tab)
time.sleep(.5) # Measure power usage of tabs after quiescence.
self._cpu_metric.Stop(page, tab) util.WaitFor(tab.HasReachedQuiescence, 60)
# Calculate the idle cpu load before any actions are done.
self._cpu_metric.AddResults(tab, results, self._power_metric.Start(page, tab)
'idle_cpu_utilization') time.sleep(5)
self._power_metric.Stop(page, tab)
self._power_metric.AddResults(tab, results,)
histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' histogram_name = 'MPArch.RWH_TabSwitchPaintDuration'
histogram_type = histogram_util.BROWSER_HISTOGRAM histogram_type = histogram_util.BROWSER_HISTOGRAM
......
{
"description": "Five blank pages.",
"pages": [
{ "url": "file://blank_page/blank_page.html" },
{ "url": "file://blank_page/blank_page.html" },
{ "url": "file://blank_page/blank_page.html" },
{ "url": "file://blank_page/blank_page.html" },
{ "url": "file://blank_page/blank_page.html" }
]
}
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