OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Basic pyauto performance tests. | 6 """Basic pyauto performance tests. |
7 | 7 |
8 For tests that need to be run for multiple iterations (e.g., so that average | 8 For tests that need to be run for multiple iterations (e.g., so that average |
9 and standard deviation values can be reported), the default number of iterations | 9 and standard deviation values can be reported), the default number of iterations |
10 run for each of these tests is specified by |_DEFAULT_NUM_ITERATIONS|. | 10 run for each of these tests is specified by |_DEFAULT_NUM_ITERATIONS|. |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 # Counting extrapolation for utilization to play the video. | 904 # Counting extrapolation for utilization to play the video. |
905 extrapolation_value = (fraction_non_idle_time * | 905 extrapolation_value = (fraction_non_idle_time * |
906 (total_frames / total_shown_frames)) | 906 (total_frames / total_shown_frames)) |
907 logging.info('Youtube CPU extrapolation: %f' % extrapolation_value) | 907 logging.info('Youtube CPU extrapolation: %f' % extrapolation_value) |
908 self._OutputPerfGraphValue( | 908 self._OutputPerfGraphValue( |
909 'YoutubeCPUExtrapolation', | 909 'YoutubeCPUExtrapolation', |
910 extrapolation_value, 'extrapolation', | 910 extrapolation_value, 'extrapolation', |
911 graph_name='YoutubeCPUExtrapolation') | 911 graph_name='YoutubeCPUExtrapolation') |
912 | 912 |
913 | 913 |
| 914 class FlashVideoPerfTest(BasePerfTest): |
| 915 """General flash video performance tests.""" |
| 916 |
| 917 def FlashVideo1080P(self): |
| 918 """Measures total dropped frames and average FPS for a 1080p flash video. |
| 919 |
| 920 This is a temporary test to be run manually for now, needed to collect some |
| 921 performance statistics across different ChromeOS devices. |
| 922 """ |
| 923 # Open up the test webpage; it's assumed the test will start automatically. |
| 924 webpage_url = 'http://www/~arscott/fl/FlashVideoTests.html' |
| 925 self.assertTrue(self.AppendTab(pyauto.GURL(webpage_url)), |
| 926 msg='Failed to append tab for webpage.') |
| 927 |
| 928 # Wait until the test is complete. |
| 929 js_is_done = """ |
| 930 window.domAutomationController.send(JSON.stringify(tests_done)); |
| 931 """ |
| 932 self.assertTrue( |
| 933 self.WaitUntil( |
| 934 lambda: self.ExecuteJavascript(js_is_done, tab_index=1) == 'true', |
| 935 timeout=300, expect_retval=True, retry_sleep=1), |
| 936 msg='Timed out when waiting for test result.') |
| 937 |
| 938 # Retrieve and output the test results. |
| 939 js_results = """ |
| 940 window.domAutomationController.send(JSON.stringify(tests_results)); |
| 941 """ |
| 942 test_result = eval(self.ExecuteJavascript(js_results, tab_index=1)) |
| 943 test_result[0] = test_result[0].replace('true', 'True') |
| 944 test_result = eval(test_result[0]) # Webpage only does 1 test right now. |
| 945 |
| 946 description = 'FlashVideo1080P' |
| 947 result = test_result['averageFPS'] |
| 948 logging.info('Result for %s: %f FPS (average)', description, result) |
| 949 self._OutputPerfGraphValue(description, result, 'FPS', |
| 950 graph_name=description) |
| 951 result = test_result['droppedFrames'] |
| 952 logging.info('Result for %s: %f dropped frames', description, result) |
| 953 self._OutputPerfGraphValue(description, result, 'DroppedFrames', |
| 954 graph_name=description) |
| 955 |
| 956 |
914 class WebGLTest(BasePerfTest): | 957 class WebGLTest(BasePerfTest): |
915 """Tests for WebGL performance.""" | 958 """Tests for WebGL performance.""" |
916 | 959 |
917 def _RunWebGLTest(self, url, description): | 960 def _RunWebGLTest(self, url, description): |
918 """Measures FPS using a specified WebGL demo. | 961 """Measures FPS using a specified WebGL demo. |
919 | 962 |
920 Args: | 963 Args: |
921 url: The string URL that, once loaded, will run the WebGL demo (default | 964 url: The string URL that, once loaded, will run the WebGL demo (default |
922 WebGL demo settings are used, since this test does not modify any | 965 WebGL demo settings are used, since this test does not modify any |
923 settings in the demo). | 966 settings in the demo). |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 """Identifies the port number to which the server is currently bound. | 1654 """Identifies the port number to which the server is currently bound. |
1612 | 1655 |
1613 Returns: | 1656 Returns: |
1614 The numeric port number to which the server is currently bound. | 1657 The numeric port number to which the server is currently bound. |
1615 """ | 1658 """ |
1616 return self._server.server_address[1] | 1659 return self._server.server_address[1] |
1617 | 1660 |
1618 | 1661 |
1619 if __name__ == '__main__': | 1662 if __name__ == '__main__': |
1620 pyauto_functional.Main() | 1663 pyauto_functional.Main() |
OLD | NEW |