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

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

Issue 350763005: [Telemetry] Power metric: subtract quiescent power draw from result (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests Created 6 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « tools/perf/measurements/smoothness_unittest.py ('k') | tools/perf/measurements/webrtc.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 """The tab switching measurement. 5 """The tab switching measurement.
6 6
7 This measurement opens pages in different tabs. After all the tabs have opened, 7 This measurement opens pages in different tabs. After all the tabs have opened,
8 it cycles through each tab in sequence, and records a histogram of the time 8 it cycles through each tab in sequence, and records a histogram of the time
9 between when a tab was first requested to be shown, and when it was painted. 9 between when a tab was first requested to be shown, and when it was painted.
10 Power usage is also measured. 10 Power usage is also measured.
11 """ 11 """
12 12
13 import time 13 import time
14 14
15 from metrics import histogram_util 15 from metrics import histogram_util
16 from metrics import power 16 from metrics import power
17 from telemetry.core import util 17 from telemetry.core import util
18 from telemetry.page import page_measurement 18 from telemetry.page import page_measurement
19 from telemetry.value import histogram 19 from telemetry.value import histogram
20 20
21 # TODO: Revisit this test once multitab support is finalized. 21 # TODO: Revisit this test once multitab support is finalized.
22 22
23 class TabSwitching(page_measurement.PageMeasurement): 23 class TabSwitching(page_measurement.PageMeasurement):
24
25 # Amount of time to measure, in seconds.
26 SAMPLE_TIME = 30
27
24 def __init__(self): 28 def __init__(self):
25 super(TabSwitching, self).__init__() 29 super(TabSwitching, self).__init__()
26 self._first_page_in_pageset = True 30 self._first_page_in_pageset = True
27 self._power_metric = power.PowerMetric() 31 self._power_metric = None
28 32
29 def CustomizeBrowserOptions(self, options): 33 def CustomizeBrowserOptions(self, options):
30 options.AppendExtraBrowserArgs([ 34 options.AppendExtraBrowserArgs([
31 '--enable-stats-collection-bindings' 35 '--enable-stats-collection-bindings'
32 ]) 36 ])
33 power.PowerMetric.CustomizeBrowserOptions(options) 37 power.PowerMetric.CustomizeBrowserOptions(options)
34 38
35 def DidStartBrowser(self, browser): 39 def WillStartBrowser(self, browser):
36 self._first_page_in_pageset = True 40 self._first_page_in_pageset = True
41 self._power_metric = power.PowerMetric(browser, TabSwitching.SAMPLE_TIME)
37 42
38 def TabForPage(self, page, browser): 43 def TabForPage(self, page, browser):
39 if self._first_page_in_pageset: 44 if self._first_page_in_pageset:
40 # The initial browser window contains a single tab, navigate that tab 45 # The initial browser window contains a single tab, navigate that tab
41 # rather than creating a new one. 46 # rather than creating a new one.
42 self._first_page_in_pageset = False 47 self._first_page_in_pageset = False
43 return browser.tabs[0] 48 return browser.tabs[0]
44 49
45 return browser.tabs.New() 50 return browser.tabs.New()
46 51
47 def StopBrowserAfterPage(self, browser, page): 52 def StopBrowserAfterPage(self, browser, page):
48 # Restart the browser after the last page in the pageset. 53 # Restart the browser after the last page in the pageset.
49 return len(browser.tabs) >= len(page.page_set.pages) 54 return len(browser.tabs) >= len(page.page_set.pages)
50 55
51 def MeasurePage(self, page, tab, results): 56 def MeasurePage(self, page, tab, results):
52 """On the last tab, cycle through each tab that was opened and then record 57 """On the last tab, cycle through each tab that was opened and then record
53 a single histogram for the tab switching metric.""" 58 a single histogram for the tab switching metric."""
54 if len(tab.browser.tabs) != len(page.page_set.pages): 59 if len(tab.browser.tabs) != len(page.page_set.pages):
55 return 60 return
56 61
57 # Measure power usage of tabs after quiescence. 62 # Measure power usage of tabs after quiescence.
58 util.WaitFor(tab.HasReachedQuiescence, 60) 63 util.WaitFor(tab.HasReachedQuiescence, 60)
59 64
60 self._power_metric.Start(page, tab) 65 self._power_metric.Start(page, tab)
61 time.sleep(60) 66 time.sleep(TabSwitching.SAMPLE_TIME)
62 self._power_metric.Stop(page, tab) 67 self._power_metric.Stop(page, tab)
63 self._power_metric.AddResults(tab, results,) 68 self._power_metric.AddResults(tab, results,)
64 69
65 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' 70 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration'
66 histogram_type = histogram_util.BROWSER_HISTOGRAM 71 histogram_type = histogram_util.BROWSER_HISTOGRAM
67 display_name = 'MPArch_RWH_TabSwitchPaintDuration' 72 display_name = 'MPArch_RWH_TabSwitchPaintDuration'
68 first_histogram = histogram_util.GetHistogram( 73 first_histogram = histogram_util.GetHistogram(
69 histogram_type, histogram_name, tab) 74 histogram_type, histogram_name, tab)
70 prev_histogram = first_histogram 75 prev_histogram = first_histogram
71 76
(...skipping 12 matching lines...) Expand all
84 89
85 last_histogram = histogram_util.GetHistogram( 90 last_histogram = histogram_util.GetHistogram(
86 histogram_type, histogram_name, tab) 91 histogram_type, histogram_name, tab)
87 diff_histogram = histogram_util.SubtractHistogram(last_histogram, 92 diff_histogram = histogram_util.SubtractHistogram(last_histogram,
88 first_histogram) 93 first_histogram)
89 94
90 results.AddSummaryValue( 95 results.AddSummaryValue(
91 histogram.HistogramValue(None, display_name, '', 96 histogram.HistogramValue(None, display_name, '',
92 raw_value_json=diff_histogram, 97 raw_value_json=diff_histogram,
93 important=False)) 98 important=False))
OLDNEW
« no previous file with comments | « tools/perf/measurements/smoothness_unittest.py ('k') | tools/perf/measurements/webrtc.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698