| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 os | 5 import os |
| 6 import unittest | 6 import unittest |
| 7 | 7 |
| 8 from telemetry import decorators | 8 from telemetry import decorators |
| 9 from telemetry.core import platform | 9 from telemetry.core import platform |
| 10 from telemetry.core import wpr_modes | 10 from telemetry.core import wpr_modes |
| 11 from telemetry.page import page as page_module | 11 from telemetry.page import page as page_module |
| 12 from telemetry.page import page_set | 12 from telemetry.page import page_set |
| 13 from telemetry.results import page_test_results | 13 from telemetry.results import page_test_results |
| 14 from telemetry.timeline import model as model_module | 14 from telemetry.timeline import model as model_module |
| 15 from telemetry.timeline import async_slice | 15 from telemetry.timeline import async_slice |
| 16 from telemetry.unittest_util import browser_test_case | 16 from telemetry.unittest_util import browser_test_case |
| 17 from telemetry.unittest_util import options_for_unittests | 17 from telemetry.unittest_util import options_for_unittests |
| 18 from telemetry.unittest_util import page_test_test_case | 18 from telemetry.unittest_util import page_test_test_case |
| 19 from telemetry.value import improvement_direction |
| 19 from telemetry.value import scalar | 20 from telemetry.value import scalar |
| 20 from telemetry.web_perf import timeline_based_measurement as tbm_module | 21 from telemetry.web_perf import timeline_based_measurement as tbm_module |
| 21 from telemetry.web_perf import timeline_interaction_record as tir_module | 22 from telemetry.web_perf import timeline_interaction_record as tir_module |
| 22 from telemetry.web_perf.metrics import timeline_based_metric | 23 from telemetry.web_perf.metrics import timeline_based_metric |
| 23 | 24 |
| 24 | 25 |
| 25 class FakeFastMetric(timeline_based_metric.TimelineBasedMetric): | 26 class FakeFastMetric(timeline_based_metric.TimelineBasedMetric): |
| 26 | 27 |
| 27 def AddResults(self, model, renderer_thread, interaction_records, results): | 28 def AddResults(self, model, renderer_thread, interaction_records, results): |
| 28 results.AddValue(scalar.ScalarValue( | 29 results.AddValue(scalar.ScalarValue( |
| 29 results.current_page, 'FakeFastMetric', 'ms', 1)) | 30 results.current_page, 'FakeFastMetric', 'ms', 1, |
| 31 improvement_direction=improvement_direction.DOWN)) |
| 30 results.AddValue(scalar.ScalarValue( | 32 results.AddValue(scalar.ScalarValue( |
| 31 results.current_page, 'FastMetricRecords', 'count', | 33 results.current_page, 'FastMetricRecords', 'count', |
| 32 len(interaction_records))) | 34 len(interaction_records), |
| 35 improvement_direction=improvement_direction.DOWN)) |
| 33 | 36 |
| 34 | 37 |
| 35 class FakeSmoothMetric(timeline_based_metric.TimelineBasedMetric): | 38 class FakeSmoothMetric(timeline_based_metric.TimelineBasedMetric): |
| 36 | 39 |
| 37 def AddResults(self, model, renderer_thread, interaction_records, results): | 40 def AddResults(self, model, renderer_thread, interaction_records, results): |
| 38 results.AddValue(scalar.ScalarValue( | 41 results.AddValue(scalar.ScalarValue( |
| 39 results.current_page, 'FakeSmoothMetric', 'ms', 1)) | 42 results.current_page, 'FakeSmoothMetric', 'ms', 1, |
| 43 improvement_direction=improvement_direction.DOWN)) |
| 40 results.AddValue(scalar.ScalarValue( | 44 results.AddValue(scalar.ScalarValue( |
| 41 results.current_page, 'SmoothMetricRecords', 'count', | 45 results.current_page, 'SmoothMetricRecords', 'count', |
| 42 len(interaction_records))) | 46 len(interaction_records), |
| 47 improvement_direction=improvement_direction.DOWN)) |
| 43 | 48 |
| 44 | 49 |
| 45 class FakeLoadingMetric(timeline_based_metric.TimelineBasedMetric): | 50 class FakeLoadingMetric(timeline_based_metric.TimelineBasedMetric): |
| 46 | 51 |
| 47 def AddResults(self, model, renderer_thread, interaction_records, results): | 52 def AddResults(self, model, renderer_thread, interaction_records, results): |
| 48 results.AddValue(scalar.ScalarValue( | 53 results.AddValue(scalar.ScalarValue( |
| 49 results.current_page, 'FakeLoadingMetric', 'ms', 2)) | 54 results.current_page, 'FakeLoadingMetric', 'ms', 2, |
| 55 improvement_direction=improvement_direction.DOWN)) |
| 50 results.AddValue(scalar.ScalarValue( | 56 results.AddValue(scalar.ScalarValue( |
| 51 results.current_page, 'LoadingMetricRecords', 'count', | 57 results.current_page, 'LoadingMetricRecords', 'count', |
| 52 len(interaction_records))) | 58 len(interaction_records), |
| 59 improvement_direction=improvement_direction.DOWN)) |
| 53 | 60 |
| 54 | 61 |
| 55 def GetMetricFromMetricType(metric_type): | 62 def GetMetricFromMetricType(metric_type): |
| 56 if metric_type == tir_module.IS_FAST: | 63 if metric_type == tir_module.IS_FAST: |
| 57 return FakeFastMetric() | 64 return FakeFastMetric() |
| 58 if metric_type == tir_module.IS_SMOOTH: | 65 if metric_type == tir_module.IS_SMOOTH: |
| 59 return FakeSmoothMetric() | 66 return FakeSmoothMetric() |
| 60 if metric_type == tir_module.IS_RESPONSIVE: | 67 if metric_type == tir_module.IS_RESPONSIVE: |
| 61 return FakeLoadingMetric() | 68 return FakeLoadingMetric() |
| 62 raise Exception('Unrecognized metric type: %s' % metric_type) | 69 raise Exception('Unrecognized metric type: %s' % metric_type) |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 # Since window.performance.now() uses wall-time instead of thread time, | 293 # Since window.performance.now() uses wall-time instead of thread time, |
| 287 # we only assert the biggest jank > 50ms here to account for the fact | 294 # we only assert the biggest jank > 50ms here to account for the fact |
| 288 # that the browser may deschedule during the jank loop. | 295 # that the browser may deschedule during the jank loop. |
| 289 v = results.FindAllPageSpecificValuesNamed( | 296 v = results.FindAllPageSpecificValuesNamed( |
| 290 'JankThreadJSRun-responsive-biggest_jank_thread_time') | 297 'JankThreadJSRun-responsive-biggest_jank_thread_time') |
| 291 self.assertGreaterEqual(v[0].value, 50) | 298 self.assertGreaterEqual(v[0].value, 50) |
| 292 | 299 |
| 293 v = results.FindAllPageSpecificValuesNamed( | 300 v = results.FindAllPageSpecificValuesNamed( |
| 294 'JankThreadJSRun-responsive-total_big_jank_thread_time') | 301 'JankThreadJSRun-responsive-total_big_jank_thread_time') |
| 295 self.assertGreaterEqual(v[0].value, 50) | 302 self.assertGreaterEqual(v[0].value, 50) |
| OLD | NEW |