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.
11 from telemetry
.page
import page_test
13 from metrics
import memory
16 class MemoryMultiTab(page_test
.PageTest
):
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
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
)
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
)