Chromium Code Reviews| 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 YoutubeTestHelper.__init__(self, self) | 598 YoutubeTestHelper.__init__(self, self) |
| 599 | 599 |
| 600 def _VerifyVideoTotalBytes(self): | 600 def _VerifyVideoTotalBytes(self): |
| 601 """Returns true if video total bytes information is available.""" | 601 """Returns true if video total bytes information is available.""" |
| 602 return self.GetVideoTotalBytes() > 0 | 602 return self.GetVideoTotalBytes() > 0 |
| 603 | 603 |
| 604 def _VerifyVideoLoadedBytes(self): | 604 def _VerifyVideoLoadedBytes(self): |
| 605 """Returns true if video loaded bytes information is available.""" | 605 """Returns true if video loaded bytes information is available.""" |
| 606 return self.GetVideoLoadedBytes() > 0 | 606 return self.GetVideoLoadedBytes() > 0 |
| 607 | 607 |
| 608 def StartVideoForPerformance(self): | 608 def StartVideoForPerformance(self, video_id='zuzaxlddWbk'): |
| 609 """Start the test video with all required buffering.""" | 609 """Start the test video with all required buffering.""" |
| 610 self.PlayVideoAndAssert() | 610 self.PlayVideoAndAssert(video_id) |
| 611 self.ExecuteJavascript(""" | 611 self.ExecuteJavascript(""" |
| 612 ytplayer.setPlaybackQuality('hd720'); | 612 ytplayer.setPlaybackQuality('hd720'); |
| 613 window.domAutomationController.send(''); | 613 window.domAutomationController.send(''); |
| 614 """) | 614 """) |
| 615 self.AssertPlayingState() | 615 self.AssertPlayingState() |
| 616 self.assertTrue( | 616 self.assertTrue( |
| 617 self.WaitUntil(self._VerifyVideoTotalBytes, expect_retval=True), | 617 self.WaitUntil(self._VerifyVideoTotalBytes, expect_retval=True), |
| 618 msg='Failed to get video total bytes information.') | 618 msg='Failed to get video total bytes information.') |
| 619 self.assertTrue( | 619 self.assertTrue( |
| 620 self.WaitUntil(self._VerifyVideoLoadedBytes, expect_retval=True), | 620 self.WaitUntil(self._VerifyVideoLoadedBytes, expect_retval=True), |
| 621 msg='Failed to get video loaded bytes information') | 621 msg='Failed to get video loaded bytes information') |
| 622 loaded_video_bytes = self.GetVideoLoadedBytes() | 622 loaded_video_bytes = self.GetVideoLoadedBytes() |
| 623 total_video_bytes = self.GetVideoTotalBytes() | 623 total_video_bytes = self.GetVideoTotalBytes() |
| 624 self.PauseVideo() | 624 self.PauseVideo() |
| 625 # Wait for the video to finish loading. | 625 # Wait for the video to finish loading. |
| 626 while total_video_bytes > loaded_video_bytes: | 626 while total_video_bytes > loaded_video_bytes: |
| 627 loaded_video_bytes = self.GetVideoLoadedBytes() | 627 loaded_video_bytes = self.GetVideoLoadedBytes() |
| 628 time.sleep(1) | 628 time.sleep(1) |
| 629 self.PlayVideo() | 629 self.PlayVideo() |
| 630 # Ignore first 10 seconds of video playing so we get smooth videoplayback. | 630 # Ignore first 10 seconds of video playing so we get smooth videoplayback. |
| 631 time.sleep(10) | 631 time.sleep(10) |
| 632 | 632 |
| 633 def testYoutubeDroppedFrames(self): | 633 def testYoutubeDroppedFrames(self): |
| 634 """Measures the Youtube video dropped frames/second. Runs for 60 secs.""" | 634 """Measures the Youtube video dropped frames/second. Runs for 60 secs. |
| 635 self.StartVideoForPerformance() | 635 |
| 636 init_dropped_frames = self.GetVideoDroppedFrames() | 636 This test measures Youtube video dropped frames for three different types |
| 637 total_dropped_frames = 0 | 637 of videos like slow, normal and fast motion. |
| 638 dropped_fps = [] | 638 """ |
| 639 for _ in xrange(60): | 639 youtube_video = {'Slow':'VT1-sitWRtY', |
| 640 frames = self.GetVideoDroppedFrames() - init_dropped_frames | 640 'Normal':'2tqK_3mKQUw', |
| 641 current_dropped_frames = frames - total_dropped_frames | 641 'Fast':'8ETDE0VGJY4', |
|
dennis_jeffrey
2011/12/01 02:44:56
add a space right after the ':' in each of the abo
rohitbm
2011/12/03 02:20:58
Done.
| |
| 642 dropped_fps.append(current_dropped_frames) | 642 } |
| 643 total_dropped_frames = frames | 643 for video_type in youtube_video: |
| 644 # Play the video for some time | 644 self.StartVideoForPerformance(youtube_video[video_type]) |
| 645 time.sleep(1) | 645 init_dropped_frames = self.GetVideoDroppedFrames() |
| 646 self._PrintSummaryResults('YoutubeDroppedFrames', dropped_fps, 'frames') | 646 total_dropped_frames = 0 |
| 647 dropped_fps = [] | |
| 648 for _ in xrange(60): | |
| 649 frames = self.GetVideoDroppedFrames() - init_dropped_frames | |
| 650 current_dropped_frames = frames - total_dropped_frames | |
| 651 dropped_fps.append(current_dropped_frames) | |
| 652 total_dropped_frames = frames | |
| 653 # Play the video for some time | |
| 654 time.sleep(1) | |
| 655 graph_description = 'YoutubeDroppedFrames' + '_' + video_type | |
|
dennis_jeffrey
2011/12/01 02:44:56
I recommend removing the '_' character that's bein
rohitbm
2011/12/03 02:20:58
Done.
| |
| 656 self._PrintSummaryResults(graph_description, dropped_fps, 'frames') | |
|
dennis_jeffrey
2011/12/01 02:44:56
Note that this change gets rid of the old perf key
ilja
2011/12/01 04:13:06
If we already are renaming I would like all Flash
dennis_jeffrey
2011/12/01 18:15:33
I'd like to create a new perf report on the autote
rohitbm
2011/12/03 02:20:58
Sure, I will remove the old graphs before submitti
dennis_jeffrey
2011/12/05 18:09:24
I recommend waiting until we enable the new graphs
| |
| 647 | 657 |
| 648 def testYoutubeCPU(self): | 658 def testYoutubeCPU(self): |
| 649 """Measures the Youtube video CPU usage. Runs for 60 seconds. | 659 """Measures the Youtube video CPU usage. Runs for 60 seconds. |
| 650 | 660 |
| 651 Measures the Youtube video CPU usage (between 0 and 1), extrapolated to | 661 Measures the Youtube video CPU usage (between 0 and 1), extrapolated to |
| 652 totalframes in the video by taking dropped frames into account. For smooth | 662 totalframes in the video by taking dropped frames into account. For smooth |
| 653 videoplayback this number should be < 0.5..1.0 on a hyperthreaded CPU. | 663 videoplayback this number should be < 0.5..1.0 on a hyperthreaded CPU. |
| 654 """ | 664 """ |
| 655 self.StartVideoForPerformance() | 665 self.StartVideoForPerformance() |
| 656 init_dropped_frames = self.GetVideoDroppedFrames() | 666 init_dropped_frames = self.GetVideoDroppedFrames() |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1457 """Identifies the port number to which the server is currently bound. | 1467 """Identifies the port number to which the server is currently bound. |
| 1458 | 1468 |
| 1459 Returns: | 1469 Returns: |
| 1460 The numeric port number to which the server is currently bound. | 1470 The numeric port number to which the server is currently bound. |
| 1461 """ | 1471 """ |
| 1462 return self._server.server_address[1] | 1472 return self._server.server_address[1] |
| 1463 | 1473 |
| 1464 | 1474 |
| 1465 if __name__ == '__main__': | 1475 if __name__ == '__main__': |
| 1466 pyauto_functional.Main() | 1476 pyauto_functional.Main() |
| OLD | NEW |