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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 782 |
783 | 783 |
784 class NetflixPerfTest(BasePerfTest, NetflixTestHelper): | 784 class NetflixPerfTest(BasePerfTest, NetflixTestHelper): |
785 """Test Netflix video performance.""" | 785 """Test Netflix video performance.""" |
786 | 786 |
787 def __init__(self, methodName='runTest', **kwargs): | 787 def __init__(self, methodName='runTest', **kwargs): |
788 pyauto.PyUITest.__init__(self, methodName, **kwargs) | 788 pyauto.PyUITest.__init__(self, methodName, **kwargs) |
789 NetflixTestHelper.__init__(self, self) | 789 NetflixTestHelper.__init__(self, self) |
790 | 790 |
791 def tearDown(self): | 791 def tearDown(self): |
792 self._SignOut() | 792 self.SignOut() |
793 pyauto.PyUITest.tearDown(self) | 793 pyauto.PyUITest.tearDown(self) |
794 | 794 |
795 def testNetflixDroppedFrames(self): | 795 def testNetflixDroppedFrames(self): |
796 """Measures the Netflix video dropped frames/second. Runs for 60 secs.""" | 796 """Measures the Netflix video dropped frames/second. Runs for 60 secs.""" |
797 self._LoginAndStartPlaying() | 797 self.LoginAndStartPlaying() |
798 self._CheckNetflixPlaying(self.IS_PLAYING, | 798 self.CheckNetflixPlaying(self.IS_PLAYING, |
799 'Player did not start playing the title.') | 799 'Player did not start playing the title.') |
800 # Ignore first 10 seconds of video playing so we get smooth videoplayback. | 800 # Ignore first 10 seconds of video playing so we get smooth videoplayback. |
801 time.sleep(10) | 801 time.sleep(10) |
802 init_dropped_frames = self._GetVideoDroppedFrames() | 802 init_dropped_frames = self._GetVideoDroppedFrames() |
803 dropped_frames = [] | 803 dropped_frames = [] |
804 prev_dropped_frames = 0 | 804 prev_dropped_frames = 0 |
805 for iteration in xrange(60): | 805 for iteration in xrange(60): |
806 # Ignoring initial dropped frames of first 10 seconds. | 806 # Ignoring initial dropped frames of first 10 seconds. |
807 total_dropped_frames = self._GetVideoDroppedFrames() - init_dropped_frames | 807 total_dropped_frames = self._GetVideoDroppedFrames() - init_dropped_frames |
808 dropped_frames_last_sec = total_dropped_frames - prev_dropped_frames | 808 dropped_frames_last_sec = total_dropped_frames - prev_dropped_frames |
809 dropped_frames.append(dropped_frames_last_sec) | 809 dropped_frames.append(dropped_frames_last_sec) |
810 logging.info('Iteration %d of %d: %f dropped frames in the last second', | 810 logging.info('Iteration %d of %d: %f dropped frames in the last second', |
811 iteration + 1, 60, dropped_frames_last_sec) | 811 iteration + 1, 60, dropped_frames_last_sec) |
812 prev_dropped_frames = total_dropped_frames | 812 prev_dropped_frames = total_dropped_frames |
813 # Play the video for some time. | 813 # Play the video for some time. |
814 time.sleep(1) | 814 time.sleep(1) |
815 self._PrintSummaryResults('NetflixDroppedFrames', dropped_frames, 'frames', | 815 self._PrintSummaryResults('NetflixDroppedFrames', dropped_frames, 'frames', |
816 'netflix_dropped_frames') | 816 'netflix_dropped_frames') |
817 | 817 |
818 def testNetflixCPU(self): | 818 def testNetflixCPU(self): |
819 """Measures the Netflix video CPU usage. Runs for 60 seconds.""" | 819 """Measures the Netflix video CPU usage. Runs for 60 seconds.""" |
820 self._LoginAndStartPlaying() | 820 self.LoginAndStartPlaying() |
821 self._CheckNetflixPlaying(self.IS_PLAYING, | 821 self.CheckNetflixPlaying(self.IS_PLAYING, |
822 'Player did not start playing the title.') | 822 'Player did not start playing the title.') |
823 # Ignore first 10 seconds of video playing so we get smooth videoplayback. | 823 # Ignore first 10 seconds of video playing so we get smooth videoplayback. |
824 time.sleep(10) | 824 time.sleep(10) |
825 init_dropped_frames = self._GetVideoDroppedFrames() | 825 init_dropped_frames = self._GetVideoDroppedFrames() |
826 init_video_frames = self._GetVideoFrames() | 826 init_video_frames = self._GetVideoFrames() |
827 cpu_usage_start = self._GetCPUUsage() | 827 cpu_usage_start = self._GetCPUUsage() |
828 total_shown_frames = 0 | 828 total_shown_frames = 0 |
829 # Play the video for some time. | 829 # Play the video for some time. |
830 time.sleep(60) | 830 time.sleep(60) |
831 total_video_frames = self._GetVideoFrames() - init_video_frames | 831 total_video_frames = self._GetVideoFrames() - init_video_frames |
832 total_dropped_frames = self._GetVideoDroppedFrames() - init_dropped_frames | 832 total_dropped_frames = self._GetVideoDroppedFrames() - init_dropped_frames |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 """Identifies the port number to which the server is currently bound. | 1990 """Identifies the port number to which the server is currently bound. |
1991 | 1991 |
1992 Returns: | 1992 Returns: |
1993 The numeric port number to which the server is currently bound. | 1993 The numeric port number to which the server is currently bound. |
1994 """ | 1994 """ |
1995 return self._server.server_address[1] | 1995 return self._server.server_address[1] |
1996 | 1996 |
1997 | 1997 |
1998 if __name__ == '__main__': | 1998 if __name__ == '__main__': |
1999 pyauto_functional.Main() | 1999 pyauto_functional.Main() |
OLD | NEW |