OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
744 'WebGLField') | 744 'WebGLField') |
745 | 745 |
746 def testWebGLSpaceRocks(self): | 746 def testWebGLSpaceRocks(self): |
747 """Measures performance using the WebGL SpaceRocks demo.""" | 747 """Measures performance using the WebGL SpaceRocks demo.""" |
748 self._RunWebGLTest( | 748 self._RunWebGLTest( |
749 self.GetFileURLForDataPath('pyauto_private', 'webgl', 'spacerocks', | 749 self.GetFileURLForDataPath('pyauto_private', 'webgl', 'spacerocks', |
750 'spacerocks.html'), | 750 'spacerocks.html'), |
751 'WebGLSpaceRocks') | 751 'WebGLSpaceRocks') |
752 | 752 |
753 | 753 |
754 class HTML5Test(BasePerfTest): | |
Nirnimesh
2011/12/07 22:55:22
Change name to HTML5BenchmarkTest
dennis_jeffrey
2011/12/07 23:04:46
Done.
| |
755 """Tests for HTML5 performance.""" | |
Nirnimesh
2011/12/07 22:55:22
It'd be nice to declare the URL here.
dennis_jeffrey
2011/12/07 23:04:46
Leaving alone as per offline discussion. The URL
| |
756 | |
757 def testHTML5Benchmark(self): | |
758 """Measures performance using the benchmark at html5-benchmark.com.""" | |
759 self.NavigateToURL('http://html5-benchmark.com') | |
760 | |
761 start_benchmark_js = """ | |
762 benchmark(); | |
763 window.domAutomationController.send("done"); | |
764 """ | |
765 self.ExecuteJavascript(start_benchmark_js) | |
766 | |
767 js_final_score = """ | |
768 var score = "-1"; | |
769 var elem = document.getElementById("score"); | |
770 if (elem) | |
771 score = elem.innerHTML; | |
772 window.domAutomationController.send(score); | |
773 """ | |
774 # Wait for the benchmark to complete, which is assumed to be when the value | |
775 # of the 'score' DOM element changes to something other than '87485'. | |
776 self.assertTrue( | |
777 self.WaitUntil( | |
778 lambda: self.ExecuteJavascript(js_final_score) != '87485', | |
779 timeout=900, retry_sleep=1), | |
780 msg='Timed out when waiting for final score to be available.') | |
781 | |
782 score = self.ExecuteJavascript(js_final_score) | |
783 logging.info('HTML5 Benchmark final score: %.2f' % float(score)) | |
784 self._OutputPerfGraphValue('score_HTML5Benchmark', float(score)) | |
785 | |
786 | |
754 class FileUploadDownloadTest(BasePerfTest): | 787 class FileUploadDownloadTest(BasePerfTest): |
755 """Tests that involve measuring performance of upload and download.""" | 788 """Tests that involve measuring performance of upload and download.""" |
756 | 789 |
757 def setUp(self): | 790 def setUp(self): |
758 """Performs necessary setup work before running each test in this class.""" | 791 """Performs necessary setup work before running each test in this class.""" |
759 self._temp_dir = tempfile.mkdtemp() | 792 self._temp_dir = tempfile.mkdtemp() |
760 self._test_server = PerfTestServer(self._temp_dir) | 793 self._test_server = PerfTestServer(self._temp_dir) |
761 self._test_server_port = self._test_server.GetPort() | 794 self._test_server_port = self._test_server.GetPort() |
762 self._test_server.Run() | 795 self._test_server.Run() |
763 self.assertTrue(self.WaitUntil(self._IsTestServerRunning), | 796 self.assertTrue(self.WaitUntil(self._IsTestServerRunning), |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1468 """Identifies the port number to which the server is currently bound. | 1501 """Identifies the port number to which the server is currently bound. |
1469 | 1502 |
1470 Returns: | 1503 Returns: |
1471 The numeric port number to which the server is currently bound. | 1504 The numeric port number to which the server is currently bound. |
1472 """ | 1505 """ |
1473 return self._server.server_address[1] | 1506 return self._server.server_address[1] |
1474 | 1507 |
1475 | 1508 |
1476 if __name__ == '__main__': | 1509 if __name__ == '__main__': |
1477 pyauto_functional.Main() | 1510 pyauto_functional.Main() |
OLD | NEW |