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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
Index: tools/perf/measurements/tab_switching.py
diff --git a/tools/perf/measurements/tab_switching.py b/tools/perf/measurements/tab_switching.py
index 9ab234f3e67d89d845c12d789313695f97edf75c..a4f7ac017a91e3f7c29b686fda6eda86ea9e8ea6 100644
--- a/tools/perf/measurements/tab_switching.py
+++ b/tools/perf/measurements/tab_switching.py
@@ -10,7 +10,6 @@
Power usage is also measured.
"""
-import json
import time
from telemetry.core import util
@@ -63,17 +62,13 @@
def ValidateAndMeasurePage(self, page, tab, results):
"""On the last tab, cycle through each tab that was opened and then record
a single histogram for the tab switching metric."""
- browser = tab.browser
- if len(browser.tabs) != len(page.story_set.stories):
+ if len(tab.browser.tabs) != len(page.story_set.stories):
return
-
- if browser.tabs < 2:
- raise Exception('Should have at least two tabs for tab switching')
# Measure power usage of tabs after quiescence.
util.WaitFor(tab.HasReachedQuiescence, 60)
- if browser.platform.CanMonitorPower():
+ if tab.browser.platform.CanMonitorPower():
self._power_metric.Start(page, tab)
time.sleep(TabSwitching.SAMPLE_TIME)
self._power_metric.Stop(page, tab)
@@ -86,31 +81,26 @@
histogram_type, histogram_name, tab)
prev_histogram = first_histogram
- for tab_to_switch in browser.tabs:
- tab_to_switch.Activate()
+ for t in tab.browser.tabs:
+ t.Activate()
def _IsDone():
cur_histogram = histogram_util.GetHistogram(
- histogram_type, histogram_name, tab_to_switch)
+ histogram_type, histogram_name, tab)
diff_histogram = histogram_util.SubtractHistogram(
cur_histogram, prev_histogram)
- # TODO(deanliao): Add SubtractHistogramRawValue to process histogram
- # object instead of JSON string.
- diff_histogram_count = json.loads(diff_histogram).get('count', 0)
- return diff_histogram_count > 0
+ return diff_histogram
util.WaitFor(_IsDone, 30)
+ prev_histogram = histogram_util.GetHistogram(
+ histogram_type, histogram_name, tab)
- # We need to get histogram again instead of getting cur_histogram as
- # variables modified inside inner function cannot be retrieved. However,
- # inner function can see external scope's variables.
- prev_histogram = histogram_util.GetHistogram(
- histogram_type, histogram_name, tab_to_switch)
+ last_histogram = histogram_util.GetHistogram(
+ histogram_type, histogram_name, tab)
+ diff_histogram = histogram_util.SubtractHistogram(last_histogram,
+ first_histogram)
- last_histogram = prev_histogram
- total_diff_histogram = histogram_util.SubtractHistogram(last_histogram,
- first_histogram)
results.AddSummaryValue(
histogram.HistogramValue(None, display_name, 'ms',
- raw_value_json=total_diff_histogram,
+ raw_value_json=diff_histogram,
important=False))
keychain_metric.KeychainMetric().AddResults(tab, results)
« 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