Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: tools/perf/measurements/memory_multi_tab.py

Issue 714273004: mac: Expose keychain access frequency to Telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mock_keychain_sleep
Patch Set: Add a common subclass to measurements. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Multi tab memory test. 5 """Multi tab memory test.
6 6
7 This test is a multi tab test, but we're interested in measurements for 7 This test is a multi tab test, but we're interested in measurements for
8 the entire test rather than each single page. 8 the entire test rather than each single page.
9 """ 9 """
10 10
11 from measurements import PageTestMeasurement
12 from metrics import memory
11 13
12 from metrics import memory 14 class MemoryMultiTab(PageTestMeasurement):
13 from telemetry.page import page_test
14
15 class MemoryMultiTab(page_test.PageTest):
16 def __init__(self, *args, **kwargs): 15 def __init__(self, *args, **kwargs):
17 super(MemoryMultiTab, self).__init__(*args, **kwargs) 16 super(MemoryMultiTab, self).__init__(*args, **kwargs)
18 self._memory_metric = None 17 self._memory_metric = None
19 # _first_tab is used to make memory measurements 18 # _first_tab is used to make memory measurements
20 self._first_tab = None 19 self._first_tab = None
21 20
22 def DidStartBrowser(self, browser): 21 def DidStartBrowser(self, browser):
23 self._memory_metric = memory.MemoryMetric(browser) 22 self._memory_metric = memory.MemoryMetric(browser)
24 23
25 def CustomizeBrowserOptions(self, options): 24 def CustomizeBrowserOptions(self, options):
25 super(MemoryMultiTab, self).CustomizeBrowserOptions(options)
26 memory.MemoryMetric.CustomizeBrowserOptions(options) 26 memory.MemoryMetric.CustomizeBrowserOptions(options)
27 # Since this is a memory benchmark, we want to sample memory histograms at 27 # Since this is a memory benchmark, we want to sample memory histograms at
28 # a high frequency. 28 # a high frequency.
29 options.AppendExtraBrowserArgs('--memory-metrics') 29 options.AppendExtraBrowserArgs('--memory-metrics')
30 30
31 def TabForPage(self, page, browser): 31 def TabForPage(self, page, browser):
32 return browser.tabs.New() 32 return browser.tabs.New()
33 33
34 def DidNavigateToPage(self, page, tab): 34 def DidNavigateToPage(self, page, tab):
35 # Start measurement on the first tab. 35 # Start measurement on the first tab.
36 if not self._first_tab: 36 if not self._first_tab:
37 self._memory_metric.Start(page, tab) 37 self._memory_metric.Start(page, tab)
38 self._first_tab = tab 38 self._first_tab = tab
39 39
40 def ValidateAndMeasurePage(self, page, tab, results): 40 def ValidateAndMeasurePage(self, page, tab, results):
41 super(MemoryMultiTab, self).ValidateAndMeasurePage(page, tab, results)
42
41 # Finalize measurement on the last tab. 43 # Finalize measurement on the last tab.
42 if len(tab.browser.tabs) == len(page.page_set.pages): 44 if len(tab.browser.tabs) == len(page.page_set.pages):
43 self._memory_metric.Stop(page, self._first_tab) 45 self._memory_metric.Stop(page, self._first_tab)
44 self._memory_metric.AddResults(self._first_tab, results) 46 self._memory_metric.AddResults(self._first_tab, results)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698