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

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

Issue 1212213003: Revert of Fix tab_switching measurement bug. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 json
14 import time 13 import time
15 14
16 from telemetry.core import util 15 from telemetry.core import util
17 from telemetry.page import page_test 16 from telemetry.page import page_test
18 from telemetry.value import histogram 17 from telemetry.value import histogram
19 from telemetry.value import histogram_util 18 from telemetry.value import histogram_util
20 19
21 from metrics import keychain_metric 20 from metrics import keychain_metric
22 from metrics import power 21 from metrics import power
23 22
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 55
57 return browser.tabs.New() 56 return browser.tabs.New()
58 57
59 def StopBrowserAfterPage(self, browser, page): 58 def StopBrowserAfterPage(self, browser, page):
60 # Restart the browser after the last page in the pageset. 59 # Restart the browser after the last page in the pageset.
61 return len(browser.tabs) >= len(page.story_set.stories) 60 return len(browser.tabs) >= len(page.story_set.stories)
62 61
63 def ValidateAndMeasurePage(self, page, tab, results): 62 def ValidateAndMeasurePage(self, page, tab, results):
64 """On the last tab, cycle through each tab that was opened and then record 63 """On the last tab, cycle through each tab that was opened and then record
65 a single histogram for the tab switching metric.""" 64 a single histogram for the tab switching metric."""
66 browser = tab.browser 65 if len(tab.browser.tabs) != len(page.story_set.stories):
67 if len(browser.tabs) != len(page.story_set.stories):
68 return 66 return
69 67
70 if browser.tabs < 2:
71 raise Exception('Should have at least two tabs for tab switching')
72
73 # Measure power usage of tabs after quiescence. 68 # Measure power usage of tabs after quiescence.
74 util.WaitFor(tab.HasReachedQuiescence, 60) 69 util.WaitFor(tab.HasReachedQuiescence, 60)
75 70
76 if browser.platform.CanMonitorPower(): 71 if tab.browser.platform.CanMonitorPower():
77 self._power_metric.Start(page, tab) 72 self._power_metric.Start(page, tab)
78 time.sleep(TabSwitching.SAMPLE_TIME) 73 time.sleep(TabSwitching.SAMPLE_TIME)
79 self._power_metric.Stop(page, tab) 74 self._power_metric.Stop(page, tab)
80 self._power_metric.AddResults(tab, results,) 75 self._power_metric.AddResults(tab, results,)
81 76
82 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration' 77 histogram_name = 'MPArch.RWH_TabSwitchPaintDuration'
83 histogram_type = histogram_util.BROWSER_HISTOGRAM 78 histogram_type = histogram_util.BROWSER_HISTOGRAM
84 display_name = 'MPArch_RWH_TabSwitchPaintDuration' 79 display_name = 'MPArch_RWH_TabSwitchPaintDuration'
85 first_histogram = histogram_util.GetHistogram( 80 first_histogram = histogram_util.GetHistogram(
86 histogram_type, histogram_name, tab) 81 histogram_type, histogram_name, tab)
87 prev_histogram = first_histogram 82 prev_histogram = first_histogram
88 83
89 for tab_to_switch in browser.tabs: 84 for t in tab.browser.tabs:
90 tab_to_switch.Activate() 85 t.Activate()
91 def _IsDone(): 86 def _IsDone():
92 cur_histogram = histogram_util.GetHistogram( 87 cur_histogram = histogram_util.GetHistogram(
93 histogram_type, histogram_name, tab_to_switch) 88 histogram_type, histogram_name, tab)
94 diff_histogram = histogram_util.SubtractHistogram( 89 diff_histogram = histogram_util.SubtractHistogram(
95 cur_histogram, prev_histogram) 90 cur_histogram, prev_histogram)
96 # TODO(deanliao): Add SubtractHistogramRawValue to process histogram 91 return diff_histogram
97 # object instead of JSON string.
98 diff_histogram_count = json.loads(diff_histogram).get('count', 0)
99 return diff_histogram_count > 0
100 util.WaitFor(_IsDone, 30) 92 util.WaitFor(_IsDone, 30)
93 prev_histogram = histogram_util.GetHistogram(
94 histogram_type, histogram_name, tab)
101 95
102 # We need to get histogram again instead of getting cur_histogram as 96 last_histogram = histogram_util.GetHistogram(
103 # variables modified inside inner function cannot be retrieved. However, 97 histogram_type, histogram_name, tab)
104 # inner function can see external scope's variables. 98 diff_histogram = histogram_util.SubtractHistogram(last_histogram,
105 prev_histogram = histogram_util.GetHistogram( 99 first_histogram)
106 histogram_type, histogram_name, tab_to_switch)
107 100
108 last_histogram = prev_histogram
109 total_diff_histogram = histogram_util.SubtractHistogram(last_histogram,
110 first_histogram)
111 results.AddSummaryValue( 101 results.AddSummaryValue(
112 histogram.HistogramValue(None, display_name, 'ms', 102 histogram.HistogramValue(None, display_name, 'ms',
113 raw_value_json=total_diff_histogram, 103 raw_value_json=diff_histogram,
114 important=False)) 104 important=False))
115 105
116 keychain_metric.KeychainMetric().AddResults(tab, results) 106 keychain_metric.KeychainMetric().AddResults(tab, results)
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/benchmark_smoke_unittest.py ('k') | tools/perf/measurements/tab_switching_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698