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

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

Issue 335243002: Convert results.Add to results.AddValue for speedindex metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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 import collections 5 import collections
6 6
7 from metrics import Metric 7 from metrics import Metric
8 from telemetry.core import bitmap 8 from telemetry.core import bitmap
9 from telemetry.value import scalar
9 10
10 11
11 class SpeedIndexMetric(Metric): 12 class SpeedIndexMetric(Metric):
12 """The speed index metric is one way of measuring page load speed. 13 """The speed index metric is one way of measuring page load speed.
13 14
14 It is meant to approximate user perception of page load speed, and it 15 It is meant to approximate user perception of page load speed, and it
15 is based on the amount of time that it takes to paint to the visual 16 is based on the amount of time that it takes to paint to the visual
16 portion of the screen. It includes paint events that occur after the 17 portion of the screen. It includes paint events that occur after the
17 onload event, and it doesn't include time loading things off-screen. 18 onload event, and it doesn't include time loading things off-screen.
18 19
(...skipping 25 matching lines...) Expand all
44 assert self.IsFinished(tab), 'Must wait for IsFinished() before Stop()' 45 assert self.IsFinished(tab), 'Must wait for IsFinished() before Stop()'
45 self._impl.Stop(tab) 46 self._impl.Stop(tab)
46 47
47 # Optional argument chart_name is not in base class Metric. 48 # Optional argument chart_name is not in base class Metric.
48 # pylint: disable=W0221 49 # pylint: disable=W0221
49 def AddResults(self, tab, results, chart_name=None): 50 def AddResults(self, tab, results, chart_name=None):
50 """Calculate the speed index and add it to the results.""" 51 """Calculate the speed index and add it to the results."""
51 index = self._impl.CalculateSpeedIndex(tab) 52 index = self._impl.CalculateSpeedIndex(tab)
52 # Release the tab so that it can be disconnected. 53 # Release the tab so that it can be disconnected.
53 self._impl = None 54 self._impl = None
54 results.Add('speed_index', 'ms', index, chart_name=chart_name) 55 results.AddValue(scalar.ScalarValue(
56 results.current_page, '%s.speed_index' % chart_name, 'ms', index))
55 57
56 def IsFinished(self, tab): 58 def IsFinished(self, tab):
57 """Decide whether the timeline recording should be stopped. 59 """Decide whether the timeline recording should be stopped.
58 60
59 When the timeline recording is stopped determines which paint events 61 When the timeline recording is stopped determines which paint events
60 are used in the speed index metric calculation. In general, the recording 62 are used in the speed index metric calculation. In general, the recording
61 should continue if there has just been some data received, because 63 should continue if there has just been some data received, because
62 this suggests that painting may continue. 64 this suggests that painting may continue.
63 65
64 A page may repeatedly request resources in an infinite loop; a timeout 66 A page may repeatedly request resources in an infinite loop; a timeout
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 frame = paint_event.args['frameId'] 298 frame = paint_event.args['frameId']
297 return (frame,) + GetBox(paint_event.args['data']['clip']) 299 return (frame,) + GetBox(paint_event.args['data']['clip'])
298 300
299 def _GroupEventByRectangle(self, paint_events): 301 def _GroupEventByRectangle(self, paint_events):
300 """Group all paint events according to the rectangle that they update.""" 302 """Group all paint events according to the rectangle that they update."""
301 result = collections.defaultdict(list) 303 result = collections.defaultdict(list)
302 for event in paint_events: 304 for event in paint_events:
303 assert event.name == 'Paint' 305 assert event.name == 'Paint'
304 result[self._GetRectangle(event)].append(event) 306 result[self._GetRectangle(event)].append(event)
305 return result 307 return result
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698