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

Side by Side Diff: tools/perf/metrics/speedindex.py

Issue 178363005: [Telemetry] Measure power in tab_switching measurement (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove extreneous change Created 6 years, 9 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
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 import collections 5 import collections
6 import os 6 import os
7 7
8 from metrics import Metric 8 from metrics import Metric
9 from telemetry.core import bitmap 9 from telemetry.core import bitmap
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 A page may repeatedly request resources in an infinite loop; a timeout 71 A page may repeatedly request resources in an infinite loop; a timeout
72 should be placed in any measurement that uses this metric, e.g.: 72 should be placed in any measurement that uses this metric, e.g.:
73 def IsDone(): 73 def IsDone():
74 return self._speedindex.IsFinished(tab) 74 return self._speedindex.IsFinished(tab)
75 util.WaitFor(IsDone, 60) 75 util.WaitFor(IsDone, 60)
76 76
77 Returns: 77 Returns:
78 True if 2 seconds have passed since last resource received, false 78 True if 2 seconds have passed since last resource received, false
79 otherwise. 79 otherwise.
80 """ 80 """
81 if self._is_finished: 81 return tab.HasReachedQuiescence()
82 return True
83
84 # The script that provides the function window.timeSinceLastResponseMs()
85 # needs to be loaded for this function, but it must be loaded AFTER
86 # the Start method is called, because if the Start method is called in
87 # the PageMeasurement's WillNavigateToPage function, then it will
88 # not be available here. The script should only be re-loaded once per page
89 # so that variables in the script get reset only for a new page.
90 if not self._script_is_loaded:
91 tab.ExecuteJavaScript(self._js)
92 self._script_is_loaded = True
93
94 time_since_last_response_ms = tab.EvaluateJavaScript(
95 "window.timeSinceLastResponseAfterLoadMs()")
96 self._is_finished = time_since_last_response_ms > 2000
97 return self._is_finished
98 82
99 83
100 class SpeedIndexImpl(object): 84 class SpeedIndexImpl(object):
101 85
102 def Start(self, tab): 86 def Start(self, tab):
103 raise NotImplementedError() 87 raise NotImplementedError()
104 88
105 def Stop(self, tab): 89 def Stop(self, tab):
106 raise NotImplementedError() 90 raise NotImplementedError()
107 91
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 frame = paint_event.args['frameId'] 302 frame = paint_event.args['frameId']
319 return (frame,) + GetBox(paint_event.args['data']['clip']) 303 return (frame,) + GetBox(paint_event.args['data']['clip'])
320 304
321 def _GroupEventByRectangle(self, paint_events): 305 def _GroupEventByRectangle(self, paint_events):
322 """Group all paint events according to the rectangle that they update.""" 306 """Group all paint events according to the rectangle that they update."""
323 result = collections.defaultdict(list) 307 result = collections.defaultdict(list)
324 for event in paint_events: 308 for event in paint_events:
325 assert event.name == 'Paint' 309 assert event.name == 'Paint'
326 result[self._GetRectangle(event)].append(event) 310 result[self._GetRectangle(event)].append(event)
327 return result 311 return result
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698