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

Side by Side Diff: tools/perf/measurements/memory_pressure.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 import logging 11 import logging
12 12
13 from measurements import PageTestMeasurement
13 from telemetry.value import histogram_util 14 from telemetry.value import histogram_util
14 from telemetry.page import page_test
15 15
16 16
17 class MemoryPressure(page_test.PageTest): 17 class MemoryPressure(PageTestMeasurement):
18 def __init__(self, *args, **kwargs): 18 def __init__(self, *args, **kwargs):
19 super(MemoryPressure, self).__init__(*args, **kwargs) 19 super(MemoryPressure, self).__init__(*args, **kwargs)
20 # _first_tab is used to access histograms 20 # _first_tab is used to access histograms
21 self._is_first_page = True 21 self._is_first_page = True
22 self._tab_count = 0 22 self._tab_count = 0
23 23
24 # Allow histogram collection 24 # Allow histogram collection
25 def CustomizeBrowserOptions(self, options): 25 def CustomizeBrowserOptions(self, options):
26 super(MemoryPressure, self).CustomizeBrowserOptions(options)
26 histogram_util.CustomizeBrowserOptions(options) 27 histogram_util.CustomizeBrowserOptions(options)
27 28
28 # Open a new tab at each page 29 # Open a new tab at each page
29 def TabForPage(self, page, browser): 30 def TabForPage(self, page, browser):
30 return browser.tabs.New() 31 return browser.tabs.New()
31 32
32 def GetTabsHistogramCounts(self, tab): 33 def GetTabsHistogramCounts(self, tab):
33 histogram_type = histogram_util.BROWSER_HISTOGRAM 34 histogram_type = histogram_util.BROWSER_HISTOGRAM
34 discard_count = histogram_util.GetHistogramCount( 35 discard_count = histogram_util.GetHistogramCount(
35 histogram_type, "Tabs.Discard.DiscardCount", tab) 36 histogram_type, "Tabs.Discard.DiscardCount", tab)
36 kill_count = histogram_util.GetHistogramCount( 37 kill_count = histogram_util.GetHistogramCount(
37 histogram_type, "Tabs.SadTab.KillCreated", tab) 38 histogram_type, "Tabs.SadTab.KillCreated", tab)
38 return (discard_count, kill_count) 39 return (discard_count, kill_count)
39 40
40 def ValidateAndMeasurePage(self, page, tab, results): 41 def ValidateAndMeasurePage(self, page, tab, results):
42 super(MemoryPressure, self).ValidateAndMeasurePage(page, tab, results)
43
41 # After navigating to each page, check if it triggered tab discards or 44 # After navigating to each page, check if it triggered tab discards or
42 # kills. 45 # kills.
43 (discard_count, kill_count) = self.GetTabsHistogramCounts(tab) 46 (discard_count, kill_count) = self.GetTabsHistogramCounts(tab)
44 47
45 # Sanity check for first page 48 # Sanity check for first page
46 if self._is_first_page: 49 if self._is_first_page:
47 self._is_first_page = False 50 self._is_first_page = False
48 assert discard_count == 0 and kill_count == 0 51 assert discard_count == 0 and kill_count == 0
49 52
50 self._tab_count += 1 53 self._tab_count += 1
51 # End the test at the first kill or discard. 54 # End the test at the first kill or discard.
52 if kill_count > 0 or discard_count > 0: 55 if kill_count > 0 or discard_count > 0:
53 logging.info("test ending at tab %d, discards = %d, kills = %d" % 56 logging.info("test ending at tab %d, discards = %d, kills = %d" %
54 (self._tab_count, discard_count, kill_count)) 57 (self._tab_count, discard_count, kill_count))
55 self.RequestExit() 58 self.RequestExit()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698