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.
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
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
)
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
)