[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / tools / perf / measurements / memory_multi_tab.py
blob818c5c8082bc2c2a537a2048774c0cd24f075539
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 """
11 from telemetry.page import page_test
13 from metrics import memory
16 class MemoryMultiTab(page_test.PageTest):
17 def __init__(self):
18 super(MemoryMultiTab, self).__init__()
19 self._memory_metric = None
20 # _first_tab is used to make memory measurements
21 self._first_tab = None
23 def DidStartBrowser(self, browser):
24 self._memory_metric = memory.MemoryMetric(browser)
26 def CustomizeBrowserOptions(self, options):
27 memory.MemoryMetric.CustomizeBrowserOptions(options)
28 # Since this is a memory benchmark, we want to sample memory histograms at
29 # a high frequency.
30 options.AppendExtraBrowserArgs('--memory-metrics')
32 def TabForPage(self, page, browser):
33 return browser.tabs.New()
35 def DidNavigateToPage(self, page, tab):
36 # Start measurement on the first tab.
37 if not self._first_tab:
38 self._memory_metric.Start(page, tab)
39 self._first_tab = tab
41 def ValidateAndMeasurePage(self, page, tab, results):
42 # Finalize measurement on the last tab.
43 if len(tab.browser.tabs) == len(page.story_set.stories):
44 self._memory_metric.Stop(page, self._first_tab)
45 self._memory_metric.AddResults(self._first_tab, results)