summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorsemenzato@chromium.org <semenzato@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-19 22:14:14 +0000
committersemenzato@chromium.org <semenzato@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-19 22:14:14 +0000
commitffd8afd8391366b1a0bdcc849d973dc1e5fee6d9 (patch)
tree49fb79253aa561e52901666c2fcce1be4e453e8a /tools/perf
parente35e1736650839e67d5ef43cc2a090b8a9e43a17 (diff)
downloadchromium_src-ffd8afd8391366b1a0bdcc849d973dc1e5fee6d9.zip
chromium_src-ffd8afd8391366b1a0bdcc849d973dc1e5fee6d9.tar.gz
chromium_src-ffd8afd8391366b1a0bdcc849d973dc1e5fee6d9.tar.bz2
Telemetry: add multitab tests framework.
Adds to Telemetry the ability to map pages to tabs instead of having all pages open sequentially in a single tab. BUG=chromium:249906 TEST=ran the modified memory_multi_tab test Review URL: https://codereview.chromium.org/26705004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/measurements/memory_multi_tab.py41
-rw-r--r--tools/perf/measurements/tab_switching.py31
-rw-r--r--tools/perf/profile_creators/small_profile_creator.py27
-rwxr-xr-xtools/perf/run_measurement3
4 files changed, 32 insertions, 70 deletions
diff --git a/tools/perf/measurements/memory_multi_tab.py b/tools/perf/measurements/memory_multi_tab.py
index 23caa0b..dacc395 100644
--- a/tools/perf/measurements/memory_multi_tab.py
+++ b/tools/perf/measurements/memory_multi_tab.py
@@ -4,26 +4,22 @@
"""Multi tab memory test.
-This test is a multi tab test. When http://crbug.com/249906 is fixed,
-this should be re-written to use that system. In the interim, this
-tricks the page runner into running for only the first page,
-then hand-navigate to other pages to do the multi tab portion of
-the test. The results for the entire test are output as if
-it is for the first page.
+This test is a multi tab test, but we're interested in measurements for
+the entire test rather than each single page.
"""
-import time
import os
from metrics import memory
from telemetry.page import page_measurement
-from telemetry.page import page_runner
from telemetry.page import page_set
class MemoryMultiTab(page_measurement.PageMeasurement):
def __init__(self, *args, **kwargs):
super(MemoryMultiTab, self).__init__(*args, **kwargs)
self._memory_metric = None
+ # _first_tab is used to make memory measurements
+ self._first_tab = None
def CreatePageSet(self, _, options):
return page_set.PageSet.FromDict({
@@ -46,29 +42,20 @@ class MemoryMultiTab(page_measurement.PageMeasurement):
# a high frequency.
options.AppendExtraBrowserArgs('--memory-metrics')
- def CanRunForPage(self, page):
- return page is page.page_set[0]
+ def TabForPage(self, page, tab):
+ return tab.browser.tabs.New()
def DidNavigateToPage(self, page, tab):
- self._memory_metric.Start(page, tab)
- # Skip the first page already loaded by the runner.
- for cur_page in page.page_set[1:]:
- # TODO(bulach): remove the sleep once there's a mechanism to ensure
- # the frame has been rendered.
- time.sleep(10)
-
- t = tab.browser.tabs.New()
-
- # We create a test_stub to be able to call 'navigate_steps' on pages
- test_stub = page_measurement.PageMeasurement()
- page_state = page_runner.PageState()
- page_state.PreparePage(cur_page, t)
- page_state.ImplicitPageNavigation(cur_page, t, test_stub)
+ # Start measurement on the first tab.
+ if not self._first_tab:
+ self._memory_metric.Start(page, tab)
+ self._first_tab = tab
def MeasurePage(self, page, tab, results):
- # Measure page before tabs are killed.
- self._memory_metric.Stop(page, tab)
- self._memory_metric.AddResults(tab, results)
+ # Finalize measurement on the last tab.
+ if len(tab.browser.tabs) == len(page.page_set.pages):
+ self._memory_metric.Stop(page, self._first_tab)
+ self._memory_metric.AddResults(self._first_tab, results)
def DidRunTest(self, tab, results):
self._memory_metric.AddSummaryResults(results)
diff --git a/tools/perf/measurements/tab_switching.py b/tools/perf/measurements/tab_switching.py
index f95b5a7..dff8041 100644
--- a/tools/perf/measurements/tab_switching.py
+++ b/tools/perf/measurements/tab_switching.py
@@ -15,7 +15,6 @@ from metrics import cpu
from metrics import histogram_util
from telemetry.core import util
from telemetry.page import page_measurement
-from telemetry.page import page_runner
# TODO: Revisit this test once multitab support is finalized.
@@ -29,33 +28,21 @@ class TabSwitching(page_measurement.PageMeasurement):
'--enable-stats-collection-bindings'
])
+ def TabForPage(self, page, tab):
+ return tab.browser.tabs.New()
+
def DidStartBrowser(self, browser):
self._cpu_metric = cpu.CpuMetric(browser)
- def CanRunForPage(self, page):
- return not page.page_set.pages.index(page)
-
- def DidNavigateToPage(self, page, tab):
- for i in xrange(1, len(page.page_set.pages)):
- t = tab.browser.tabs.New()
-
- # We create a test_stub to be able to call 'navigate_steps' on pages
- test_stub = page_measurement.PageMeasurement()
- page_state = page_runner.PageState()
- page_state.PreparePage(page.page_set.pages[i], t)
- page_state.ImplicitPageNavigation(page.page_set.pages[i], t, test_stub)
-
- # Start tracking cpu load after all pages have loaded.
- self._cpu_metric.Start(page, tab)
-
def MeasurePage(self, page, tab, results):
- """Although this is called MeasurePage, we're actually using this function
- to cycle through each tab that was opened via DidNavigateToPage and
- then record a single histogram for the tab switching metric.
- """
- # Calculate the idle cpu load before any actions are done.
+ """On the last tab, cycle through each tab that was opened and then record
+ a single histogram for the tab switching metric."""
+ if len(tab.browser.tabs) != len(page.page_set.pages):
+ return
+ self._cpu_metric.Start(page, tab)
time.sleep(.5)
self._cpu_metric.Stop(page, tab)
+ # Calculate the idle cpu load before any actions are done.
self._cpu_metric.AddResults(tab, results,
'idle_cpu_utilization')
diff --git a/tools/perf/profile_creators/small_profile_creator.py b/tools/perf/profile_creators/small_profile_creator.py
index 69fb0f9..0f51a60 100644
--- a/tools/perf/profile_creators/small_profile_creator.py
+++ b/tools/perf/profile_creators/small_profile_creator.py
@@ -6,7 +6,6 @@ import os
from telemetry.core import util
from telemetry.page import page_set
-from telemetry.page import page_runner
from telemetry.page import profile_creator
class SmallProfileCreator(profile_creator.ProfileCreator):
@@ -19,29 +18,17 @@ class SmallProfileCreator(profile_creator.ProfileCreator):
typical_25 = os.path.join(util.GetBaseDir(), 'page_sets', 'typical_25.json')
self._page_set = page_set.PageSet.FromFile(typical_25)
- # Open all links in the same tab save for the last N_NUM_TABS links which
+ # Open all links in the same tab save for the last _NUM_TABS links which
# are each opened in a new tab.
self._NUM_TABS = 5
- def CanRunForPage(self, page):
+ def TabForPage(self, page, tab):
idx = page.page_set.pages.index(page)
- return idx <= (len(page.page_set.pages) - self._NUM_TABS)
-
- def DidNavigateToPage(self, page, tab):
- num_pages_in_pageset = len(page.page_set.pages)
- last_tab_loaded_automatically = num_pages_in_pageset - self._NUM_TABS
- page_index = page.page_set.pages.index(page)
- if (page_index == last_tab_loaded_automatically):
- for i in xrange(last_tab_loaded_automatically + 1, num_pages_in_pageset):
- # Load the last _NUM_TABS pages, each in a new tab.
- t = tab.browser.tabs.New()
-
- page_state = page_runner.PageState()
- page_state.PreparePage(page.page_set.pages[i], t)
- page_state.ImplicitPageNavigation(page.page_set.pages[i], t)
-
- t.WaitForDocumentReadyStateToBeInteractiveOrBetter()
-
+ # The last _NUM_TABS pages open a new tab.
+ if idx <= (len(page.page_set.pages) - self._NUM_TABS):
+ return tab
+ else:
+ return tab.browser.tabs.New()
def MeasurePage(self, _, tab, results):
# Can't use WaitForDocumentReadyStateToBeComplete() here due to
diff --git a/tools/perf/run_measurement b/tools/perf/run_measurement
index 30df716..7877041 100755
--- a/tools/perf/run_measurement
+++ b/tools/perf/run_measurement
@@ -84,7 +84,8 @@ def main():
}
# There are bots that are hard-coded to run some specific named tests.
- # Convert these to the current naming conventions by overriding them in the runner.
+ # Convert these to the current naming conventions by overriding them
+ # in the runner.
class MeasurementRunner(page_measurement_runner.PageMeasurementRunner):
def GetModernizedTestName(self, arg):
if arg not in old_benchmark_names: