Change next_proto member type.
[chromium-blink-merge.git] / tools / perf / measurements / memory_multi_tab.py
blobe6891512d5beb1244fa2c83f416bae999314560d
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Multi tab memory test.
7 This test is a multi tab test, but we're interested in measurements for
8 the entire test rather than each single page.
9 """
12 from metrics import memory
13 from telemetry.page import page_test
15 class MemoryMultiTab(page_test.PageTest):
16 def __init__(self, *args, **kwargs):
17 super(MemoryMultiTab, self).__init__(*args, **kwargs)
18 self._memory_metric = None
19 # _first_tab is used to make memory measurements
20 self._first_tab = None
22 def DidStartBrowser(self, browser):
23 self._memory_metric = memory.MemoryMetric(browser)
25 def CustomizeBrowserOptions(self, options):
26 memory.MemoryMetric.CustomizeBrowserOptions(options)
27 # Since this is a memory benchmark, we want to sample memory histograms at
28 # a high frequency.
29 options.AppendExtraBrowserArgs('--memory-metrics')
31 def TabForPage(self, page, browser):
32 return browser.tabs.New()
34 def DidNavigateToPage(self, page, tab):
35 # Start measurement on the first tab.
36 if not self._first_tab:
37 self._memory_metric.Start(page, tab)
38 self._first_tab = tab
40 def ValidateAndMeasurePage(self, page, tab, results):
41 # Finalize measurement on the last tab.
42 if len(tab.browser.tabs) == len(page.page_set.pages):
43 self._memory_metric.Stop(page, self._first_tab)
44 self._memory_metric.AddResults(self._first_tab, results)