OLD | NEW |
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 import os | 4 import os |
5 import math | 5 import math |
6 | 6 |
7 from telemetry.core import util | 7 from telemetry.core import util |
8 from metrics import discrepancy | 8 from metrics import discrepancy |
9 | 9 |
10 TIMELINE_MARKER = 'smoothness_scroll' | 10 TIMELINE_MARKER = 'smoothness_scroll' |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 return total | 80 return total |
81 | 81 |
82 def Average(numerator, denominator, scale = None, precision = None): | 82 def Average(numerator, denominator, scale = None, precision = None): |
83 numerator_total = Total(numerator) | 83 numerator_total = Total(numerator) |
84 denominator_total = Total(denominator) | 84 denominator_total = Total(denominator) |
85 if denominator_total == 0: | 85 if denominator_total == 0: |
86 return 0 | 86 return 0 |
87 avg = numerator_total / denominator_total | 87 avg = numerator_total / denominator_total |
88 if scale: | 88 if scale: |
89 avg *= scale | 89 avg *= scale |
90 if precision: | 90 if precision == None: |
| 91 pass |
| 92 elif precision == 0: |
| 93 avg = int(avg) |
| 94 else: |
91 avg = round(avg, precision) | 95 avg = round(avg, precision) |
92 return avg | 96 return avg |
93 | 97 |
94 def DivideIfPossibleOrZero(numerator, denominator): | 98 def DivideIfPossibleOrZero(numerator, denominator): |
95 if not denominator: | 99 if not denominator: |
96 return 0.0 | 100 return 0.0 |
97 else: | 101 else: |
98 return numerator / denominator | 102 return numerator / denominator |
99 | 103 |
100 def GeneralizedMean(values, exponent): | 104 def GeneralizedMean(values, exponent): |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 results.Add('mean_frame_time', 'ms', | 172 results.Add('mean_frame_time', 'ms', |
169 Average(s.total_time, s.screen_frame_count, 1000, 3)) | 173 Average(s.total_time, s.screen_frame_count, 1000, 3)) |
170 # Absolute discrepancy of frame time stamps. | 174 # Absolute discrepancy of frame time stamps. |
171 results.Add('jank', '', | 175 results.Add('jank', '', |
172 round(discrepancy.FrameDiscrepancy(s.screen_frame_timestamps, | 176 round(discrepancy.FrameDiscrepancy(s.screen_frame_timestamps, |
173 True), 4)) | 177 True), 4)) |
174 # Are we hitting 60 fps for 95 percent of all frames? | 178 # Are we hitting 60 fps for 95 percent of all frames? |
175 # We use 17ms as a slightly looser threshold, instead of 1000.0/60.0. | 179 # We use 17ms as a slightly looser threshold, instead of 1000.0/60.0. |
176 results.Add('mostly_smooth', '', | 180 results.Add('mostly_smooth', '', |
177 Percentile(frame_times, 95.0) < 17.0) | 181 Percentile(frame_times, 95.0) < 17.0) |
OLD | NEW |