Commit fb47659a authored by ariblue's avatar ariblue Committed by Commit bot

NotEnoughFramesError no longer raises an exception.

Instead, it causes smoothness metrics to have None values. Additionaly,
the smoothness metric in smoothness.py has been refactored to more
easily support (the newly added) unit tests.

BUG=

Review URL: https://codereview.chromium.org/476363002

Cr-Commit-Position: refs/heads/master@{#292201}
parent 13d9e53b
# Copyright 2014 The Chromium Authors. All rights reserved. # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import logging
from operator import attrgetter from operator import attrgetter
from telemetry.page import page_test
from telemetry.web_perf.metrics import rendering_frame from telemetry.web_perf.metrics import rendering_frame
# These are LatencyInfo component names indicating the various components # These are LatencyInfo component names indicating the various components
...@@ -30,19 +28,6 @@ SCROLL_UPDATE_EVENT_NAME = 'InputLatency:ScrollUpdate' ...@@ -30,19 +28,6 @@ SCROLL_UPDATE_EVENT_NAME = 'InputLatency:ScrollUpdate'
GESTURE_SCROLL_UPDATE_EVENT_NAME = 'InputLatency:GestureScrollUpdate' GESTURE_SCROLL_UPDATE_EVENT_NAME = 'InputLatency:GestureScrollUpdate'
class NotEnoughFramesError(page_test.MeasurementFailure):
def __init__(self, frame_count):
super(NotEnoughFramesError, self).__init__(
'Only %i frame timestamps were collected ' % frame_count +
'(at least two are required).\n'
'Issues that have caused this in the past:\n' +
'- Browser bugs that prevents the page from redrawing\n' +
'- Bugs in the synthetic gesture code\n' +
'- Page and benchmark out of sync (e.g. clicked element was renamed)\n' +
'- Pages that render extremely slow\n' +
'- Pages that can\'t be scrolled')
def GetInputLatencyEvents(process, timeline_range): def GetInputLatencyEvents(process, timeline_range):
"""Get input events' LatencyInfo from the process's trace buffer that are """Get input events' LatencyInfo from the process's trace buffer that are
within the timeline_range. within the timeline_range.
...@@ -139,7 +124,11 @@ class RenderingStats(object): ...@@ -139,7 +124,11 @@ class RenderingStats(object):
if HasRenderingStats(browser_process): if HasRenderingStats(browser_process):
timestamp_process = browser_process timestamp_process = browser_process
else: else:
timestamp_process = renderer_process timestamp_process = renderer_process
# A lookup from list names below to any errors or exceptions encountered
# in attempting to generate that list.
self.errors = {}
self.frame_timestamps = [] self.frame_timestamps = []
self.frame_times = [] self.frame_times = []
...@@ -186,12 +175,6 @@ class RenderingStats(object): ...@@ -186,12 +175,6 @@ class RenderingStats(object):
self._InitFrameQueueingDurationsFromTimeline( self._InitFrameQueueingDurationsFromTimeline(
renderer_process, timeline_range) renderer_process, timeline_range)
# Check if we have collected at least 2 frames in every range. Otherwise we
# can't compute any meaningful metrics.
for segment in self.frame_timestamps:
if len(segment) < 2:
raise NotEnoughFramesError(len(segment))
def _InitInputLatencyStatsFromTimeline( def _InitInputLatencyStatsFromTimeline(
self, browser_process, renderer_process, timeline_range): self, browser_process, renderer_process, timeline_range):
latency_events = GetInputLatencyEvents(browser_process, timeline_range) latency_events = GetInputLatencyEvents(browser_process, timeline_range)
...@@ -271,5 +254,5 @@ class RenderingStats(object): ...@@ -271,5 +254,5 @@ class RenderingStats(object):
new_frame_queueing_durations = [e.queueing_duration for e in events] new_frame_queueing_durations = [e.queueing_duration for e in events]
self.frame_queueing_durations.append(new_frame_queueing_durations) self.frame_queueing_durations.append(new_frame_queueing_durations)
except rendering_frame.NoBeginFrameIdException: except rendering_frame.NoBeginFrameIdException:
logging.warning('Current chrome version does not support the queueing ' self.errors['frame_queueing_durations'] = (
'delay metric.') 'Current chrome version does not support the queueing delay metric.')
...@@ -23,7 +23,6 @@ from telemetry.web_perf.metrics.rendering_stats import ( ...@@ -23,7 +23,6 @@ from telemetry.web_perf.metrics.rendering_stats import (
ComputeInputEventLatencies) ComputeInputEventLatencies)
from telemetry.web_perf.metrics.rendering_stats import GetInputLatencyEvents from telemetry.web_perf.metrics.rendering_stats import GetInputLatencyEvents
from telemetry.web_perf.metrics.rendering_stats import HasRenderingStats from telemetry.web_perf.metrics.rendering_stats import HasRenderingStats
from telemetry.web_perf.metrics.rendering_stats import NotEnoughFramesError
from telemetry.web_perf.metrics.rendering_stats import RenderingStats from telemetry.web_perf.metrics.rendering_stats import RenderingStats
...@@ -302,8 +301,10 @@ class RenderingStatsUnitTest(unittest.TestCase): ...@@ -302,8 +301,10 @@ class RenderingStatsUnitTest(unittest.TestCase):
timeline_markers = timeline.FindTimelineMarkers(['ActionA', 'ActionB']) timeline_markers = timeline.FindTimelineMarkers(['ActionA', 'ActionB'])
timeline_ranges = [ timeline_bounds.Bounds.CreateFromEvent(marker) timeline_ranges = [ timeline_bounds.Bounds.CreateFromEvent(marker)
for marker in timeline_markers ] for marker in timeline_markers ]
self.assertRaises(NotEnoughFramesError, RenderingStats,
renderer, None, timeline_ranges) stats = RenderingStats(renderer, None, timeline_ranges)
self.assertEquals(0, len(stats.frame_timestamps[1]))
def testFromTimeline(self): def testFromTimeline(self):
timeline = model.TimelineModel() timeline = model.TimelineModel()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment