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

Side by Side Diff: build/android/pylib/perf/surface_stats_collector.py

Issue 132463007: Enable presubmit pylint in build/android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase vs tot and only disabling F0401 in specific spots Created 6 years, 10 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 import Queue 5 import Queue
6 import datetime 6 import datetime
7 import logging 7 import logging
8 import re 8 import re
9 import threading 9 import threading
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 def SampleResults(self): 65 def SampleResults(self):
66 self._StorePerfResults() 66 self._StorePerfResults()
67 results = self.GetResults() 67 results = self.GetResults()
68 self._results = [] 68 self._results = []
69 return results 69 return results
70 70
71 def GetResults(self): 71 def GetResults(self):
72 return self._results or self._GetEmptyResults() 72 return self._results or self._GetEmptyResults()
73 73
74 def _GetEmptyResults(self): 74 @staticmethod
75 def _GetEmptyResults():
75 return [ 76 return [
76 SurfaceStatsCollector.Result('refresh_period', None, 'seconds'), 77 SurfaceStatsCollector.Result('refresh_period', None, 'seconds'),
77 SurfaceStatsCollector.Result('jank_count', None, 'janks'), 78 SurfaceStatsCollector.Result('jank_count', None, 'janks'),
78 SurfaceStatsCollector.Result('max_frame_delay', None, 'vsyncs'), 79 SurfaceStatsCollector.Result('max_frame_delay', None, 'vsyncs'),
79 SurfaceStatsCollector.Result('frame_lengths', None, 'vsyncs'), 80 SurfaceStatsCollector.Result('frame_lengths', None, 'vsyncs'),
80 SurfaceStatsCollector.Result('avg_surface_fps', None, 'fps') 81 SurfaceStatsCollector.Result('avg_surface_fps', None, 'fps')
81 ] 82 ]
82 83
83 @staticmethod 84 @staticmethod
84 def _GetNormalizedDeltas(data, refresh_period, min_normalized_delta=None): 85 def _GetNormalizedDeltas(data, refresh_period, min_normalized_delta=None):
(...skipping 10 matching lines...) Expand all
95 seconds = timestamps[-1] - timestamps[0] 96 seconds = timestamps[-1] - timestamps[0]
96 97
97 frame_lengths, normalized_frame_lengths = \ 98 frame_lengths, normalized_frame_lengths = \
98 SurfaceStatsCollector._GetNormalizedDeltas( 99 SurfaceStatsCollector._GetNormalizedDeltas(
99 timestamps, refresh_period, _MIN_NORMALIZED_FRAME_LENGTH) 100 timestamps, refresh_period, _MIN_NORMALIZED_FRAME_LENGTH)
100 if len(frame_lengths) < frame_count - 1: 101 if len(frame_lengths) < frame_count - 1:
101 logging.warning('Skipping frame lengths that are too short.') 102 logging.warning('Skipping frame lengths that are too short.')
102 frame_count = len(frame_lengths) + 1 103 frame_count = len(frame_lengths) + 1
103 if len(frame_lengths) == 0: 104 if len(frame_lengths) == 0:
104 raise Exception('No valid frames lengths found.') 105 raise Exception('No valid frames lengths found.')
105 length_changes, normalized_changes = \ 106 _length_changes, normalized_changes = \
106 SurfaceStatsCollector._GetNormalizedDeltas( 107 SurfaceStatsCollector._GetNormalizedDeltas(
107 frame_lengths, refresh_period) 108 frame_lengths, refresh_period)
108 jankiness = [max(0, round(change)) for change in normalized_changes] 109 jankiness = [max(0, round(change)) for change in normalized_changes]
109 pause_threshold = 20 110 pause_threshold = 20
110 jank_count = sum(1 for change in jankiness 111 jank_count = sum(1 for change in jankiness
111 if change > 0 and change < pause_threshold) 112 if change > 0 and change < pause_threshold)
112 return [ 113 return [
113 SurfaceStatsCollector.Result( 114 SurfaceStatsCollector.Result(
114 'avg_surface_fps' + result_suffix, 115 'avg_surface_fps' + result_suffix,
115 int(round((frame_count - 1) / seconds)), 'fps'), 116 int(round((frame_count - 1) / seconds)), 'fps'),
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 try: 299 try:
299 cur_surface = int(match.group(1), 16) 300 cur_surface = int(match.group(1), 16)
300 except Exception: 301 except Exception:
301 logging.error('Failed to parse current surface from ' + match.group(1)) 302 logging.error('Failed to parse current surface from ' + match.group(1))
302 else: 303 else:
303 logging.warning('Failed to call SurfaceFlinger surface ' + results[0]) 304 logging.warning('Failed to call SurfaceFlinger surface ' + results[0])
304 return { 305 return {
305 'page_flip_count': cur_surface, 306 'page_flip_count': cur_surface,
306 'timestamp': datetime.datetime.now(), 307 'timestamp': datetime.datetime.now(),
307 } 308 }
OLDNEW
« no previous file with comments | « build/android/pylib/perf/setup.py ('k') | build/android/pylib/perf/surface_stats_collector_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698