OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 from telemetry import multi_page_benchmark_unittest_base | 4 from telemetry import multi_page_benchmark_unittest_base |
5 from telemetry import page | 5 from telemetry import page |
6 from perf_tools import smoothness_benchmark | 6 from perf_tools import smoothness_benchmark |
7 | 7 |
8 from telemetry.page_benchmark_results import PageBenchmarkResults | 8 from telemetry.page_benchmark_results import PageBenchmarkResults |
9 | 9 |
10 class SmoothnessBenchmarkUnitTest( | 10 class SmoothnessBenchmarkUnitTest( |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 self.assertTrue('dropped_percent' in results0) | 38 self.assertTrue('dropped_percent' in results0) |
39 self.assertTrue('mean_frame_time' in results0) | 39 self.assertTrue('mean_frame_time' in results0) |
40 | 40 |
41 def testCalcResultsFromRAFRenderStats(self): | 41 def testCalcResultsFromRAFRenderStats(self): |
42 rendering_stats = {'droppedFrameCount': 5, | 42 rendering_stats = {'droppedFrameCount': 5, |
43 'totalTimeInSeconds': 1, | 43 'totalTimeInSeconds': 1, |
44 'numAnimationFrames': 10, | 44 'numAnimationFrames': 10, |
45 'numFramesSentToScreen': 10} | 45 'numFramesSentToScreen': 10} |
46 res = PageBenchmarkResults() | 46 res = PageBenchmarkResults() |
47 res.WillMeasurePage(page.Page('http://foo.com/')) | 47 res.WillMeasurePage(page.Page('http://foo.com/', None)) |
48 smoothness_benchmark.CalcScrollResults(rendering_stats, res) | 48 smoothness_benchmark.CalcScrollResults(rendering_stats, res) |
49 res.DidMeasurePage() | 49 res.DidMeasurePage() |
50 self.assertEquals(50, res.page_results[0]['dropped_percent'].value) | 50 self.assertEquals(50, res.page_results[0]['dropped_percent'].value) |
51 self.assertAlmostEquals( | 51 self.assertAlmostEquals( |
52 100, | 52 100, |
53 res.page_results[0]['mean_frame_time'].value, 2) | 53 res.page_results[0]['mean_frame_time'].value, 2) |
54 | 54 |
55 def testCalcResultsRealRenderStats(self): | 55 def testCalcResultsRealRenderStats(self): |
56 rendering_stats = {'numFramesSentToScreen': 60, | 56 rendering_stats = {'numFramesSentToScreen': 60, |
57 'globalTotalTextureUploadTimeInSeconds': 0, | 57 'globalTotalTextureUploadTimeInSeconds': 0, |
58 'totalProcessingCommandsTimeInSeconds': 0, | 58 'totalProcessingCommandsTimeInSeconds': 0, |
59 'globalTextureUploadCount': 0, | 59 'globalTextureUploadCount': 0, |
60 'droppedFrameCount': 0, | 60 'droppedFrameCount': 0, |
61 'textureUploadCount': 0, | 61 'textureUploadCount': 0, |
62 'numAnimationFrames': 10, | 62 'numAnimationFrames': 10, |
63 'totalPaintTimeInSeconds': 0.35374299999999986, | 63 'totalPaintTimeInSeconds': 0.35374299999999986, |
64 'globalTotalProcessingCommandsTimeInSeconds': 0, | 64 'globalTotalProcessingCommandsTimeInSeconds': 0, |
65 'totalTextureUploadTimeInSeconds': 0, | 65 'totalTextureUploadTimeInSeconds': 0, |
66 'totalRasterizeTimeInSeconds': 0, | 66 'totalRasterizeTimeInSeconds': 0, |
67 'totalTimeInSeconds': 1.0} | 67 'totalTimeInSeconds': 1.0} |
68 res = PageBenchmarkResults() | 68 res = PageBenchmarkResults() |
69 res.WillMeasurePage(page.Page('http://foo.com/')) | 69 res.WillMeasurePage(page.Page('http://foo.com/', None)) |
70 smoothness_benchmark.CalcScrollResults(rendering_stats, res) | 70 smoothness_benchmark.CalcScrollResults(rendering_stats, res) |
71 res.DidMeasurePage() | 71 res.DidMeasurePage() |
72 self.assertEquals(0, res.page_results[0]['dropped_percent'].value) | 72 self.assertEquals(0, res.page_results[0]['dropped_percent'].value) |
73 self.assertAlmostEquals( | 73 self.assertAlmostEquals( |
74 1000/60., | 74 1000/60., |
75 res.page_results[0]['mean_frame_time'].value, 2) | 75 res.page_results[0]['mean_frame_time'].value, 2) |
76 | 76 |
77 def testDoesImplThreadScroll(self): | 77 def testDoesImplThreadScroll(self): |
78 ps = self.CreatePageSetFromFileInUnittestDataDir('scrollable_page.html') | 78 ps = self.CreatePageSetFromFileInUnittestDataDir('scrollable_page.html') |
79 | 79 |
(...skipping 10 matching lines...) Expand all Loading... |
90 benchmark = smoothness_benchmark.SmoothnessBenchmark() | 90 benchmark = smoothness_benchmark.SmoothnessBenchmark() |
91 benchmark.use_gpu_benchmarking_extension = False | 91 benchmark.use_gpu_benchmarking_extension = False |
92 all_results = self.RunBenchmark(benchmark, ps) | 92 all_results = self.RunBenchmark(benchmark, ps) |
93 | 93 |
94 self.assertEqual(0, len(all_results.page_failures)) | 94 self.assertEqual(0, len(all_results.page_failures)) |
95 self.assertEqual(1, len(all_results.page_results)) | 95 self.assertEqual(1, len(all_results.page_results)) |
96 results0 = all_results.page_results[0] | 96 results0 = all_results.page_results[0] |
97 | 97 |
98 self.assertTrue('dropped_percent' in results0) | 98 self.assertTrue('dropped_percent' in results0) |
99 self.assertTrue('mean_frame_time' in results0) | 99 self.assertTrue('mean_frame_time' in results0) |
OLD | NEW |