OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/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 27 matching lines...) Expand all Loading... | |
38 import urllib2 | 38 import urllib2 |
39 import urlparse | 39 import urlparse |
40 | 40 |
41 import pyauto_functional # Must be imported before pyauto. | 41 import pyauto_functional # Must be imported before pyauto. |
42 import pyauto | 42 import pyauto |
43 | 43 |
44 import perf_snapshot | 44 import perf_snapshot |
45 import pyauto_utils | 45 import pyauto_utils |
46 import test_utils | 46 import test_utils |
47 from youtube import YoutubeTestHelper | 47 from youtube import YoutubeTestHelper |
48 from netflix import NetflixTestHelper | |
dennis_jeffrey
2011/11/21 22:45:10
Move this up right before line 44, so that the app
rohitbm
2011/11/22 00:57:09
Done.
| |
48 | 49 |
49 | 50 |
50 class BasePerfTest(pyauto.PyUITest): | 51 class BasePerfTest(pyauto.PyUITest): |
51 """Base class for performance tests.""" | 52 """Base class for performance tests.""" |
52 | 53 |
53 _DEFAULT_NUM_ITERATIONS = 50 | 54 _DEFAULT_NUM_ITERATIONS = 50 |
54 _DEFAULT_MAX_TIMEOUT_COUNT = 10 | 55 _DEFAULT_MAX_TIMEOUT_COUNT = 10 |
55 _PERF_OUTPUT_MARKER_PRE = '_PERF_PRE_' | 56 _PERF_OUTPUT_MARKER_PRE = '_PERF_PRE_' |
56 _PERF_OUTPUT_MARKER_POST = '_PERF_POST_' | 57 _PERF_OUTPUT_MARKER_POST = '_PERF_POST_' |
57 | 58 |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 def _RunSingleDocsTabOpen(): | 531 def _RunSingleDocsTabOpen(): |
531 self._AppendTab('http://docs.google.com') | 532 self._AppendTab('http://docs.google.com') |
532 self.assertTrue(self.WaitUntil(_SubstringExistsOnPage, timeout=120, | 533 self.assertTrue(self.WaitUntil(_SubstringExistsOnPage, timeout=120, |
533 expect_retval='true', retry_sleep=0.10), | 534 expect_retval='true', retry_sleep=0.10), |
534 msg='Timed out waiting for expected Docs string.') | 535 msg='Timed out waiting for expected Docs string.') |
535 | 536 |
536 self._LoginToGoogleAccount() | 537 self._LoginToGoogleAccount() |
537 self._RunNewTabTest('NewTabDocs', _RunSingleDocsTabOpen) | 538 self._RunNewTabTest('NewTabDocs', _RunSingleDocsTabOpen) |
538 | 539 |
539 | 540 |
541 class NetflixPerfTest(BasePerfTest, NetflixTestHelper): | |
542 """Test Netflix video performance.""" | |
543 | |
544 def __init__(self, methodName='runTest', **kwargs): | |
545 pyauto.PyUITest.__init__(self, methodName, **kwargs) | |
546 NetflixTestHelper.__init__(self, self) | |
547 | |
548 def tearDown(self): | |
549 self._SignOut() | |
550 pyauto.PyUITest.tearDown(self) | |
551 | |
552 def testNetflixDroppedFrames(self): | |
553 """Measures the Netflix video dropped frames. Runs for 60 secs.""" | |
dennis_jeffrey
2011/11/21 22:45:10
Clarify that this test measures the dropped frames
rohitbm
2011/11/22 00:57:09
Done.
| |
554 self._LoginAndStartPlaying() | |
555 # Ignore first 10 seconds of video playing so we get smooth videoplayback. | |
556 time.sleep(10) | |
557 init_dropped_frames = self.GetVideoDroppedFrames() | |
558 dropped_frames = [] | |
559 prev_dropped_frames = 0 | |
560 for _ in xrange(60): | |
561 # Ignoring initial dropped frames of first 10 seconds. | |
562 total_dropped_frames = self.GetVideoDroppedFrames() - init_dropped_frames | |
563 dropped_frames.append(total_dropped_frames - prev_dropped_frames) | |
564 prev_dropped_frames = total_dropped_frames | |
565 # Play the video for some time. | |
566 time.sleep(1) | |
567 self._PrintSummaryResults('NetflixDroppedFrames', dropped_frames, 'frames') | |
568 | |
569 def testNetflixCPU(self): | |
570 """Measures the Netflix video CPU usage. Runs for 60 seconds.""" | |
571 self._LoginAndStartPlaying() | |
572 # Ignore first 10 seconds of video playing so we get smooth videoplayback. | |
573 time.sleep(10) | |
574 init_dropped_frames = self.GetVideoDroppedFrames() | |
575 init_video_frames = self.GetVideoFrames() | |
576 cpu_usage_start = self._GetCPUUsage() | |
577 total_shown_frames = 0 | |
578 # Play the video for some time. | |
579 time.sleep(60) | |
580 total_video_frames = self.GetVideoFrames() - init_video_frames | |
581 total_dropped_frames = self.GetVideoDroppedFrames() - init_dropped_frames | |
582 cpu_usage_end = self._GetCPUUsage() | |
583 fraction_non_idle_time =\ | |
dennis_jeffrey
2011/11/21 22:45:10
nit: put a space right before the \
rohitbm
2011/11/22 00:57:09
Done.
| |
584 self._GetFractionNonIdleCPUTime(cpu_usage_start, cpu_usage_end) | |
585 # Counting extrapolation for utilization to play the video. | |
586 extrapolation_value = fraction_non_idle_time *\ | |
dennis_jeffrey
2011/11/21 22:45:10
nit: put a space right before the \
rohitbm
2011/11/22 00:57:09
Done.
| |
587 (total_video_frames + total_dropped_frames)/total_video_frames | |
dennis_jeffrey
2011/11/21 22:45:10
add spaces right before and right after the /
rohitbm
2011/11/22 00:57:09
Done.
| |
588 logging.info('Netflix CPU extrapolation: %.2f' % extrapolation_value) | |
589 self._OutputPerfGraphValue('extrapolation_NetflixCPUExtrapolation', | |
590 extrapolation_value) | |
591 | |
592 | |
540 class YoutubePerfTest(BasePerfTest, YoutubeTestHelper): | 593 class YoutubePerfTest(BasePerfTest, YoutubeTestHelper): |
541 """Test Youtube video performance.""" | 594 """Test Youtube video performance.""" |
542 | 595 |
543 def __init__(self, methodName='runTest', **kwargs): | 596 def __init__(self, methodName='runTest', **kwargs): |
544 pyauto.PyUITest.__init__(self, methodName, **kwargs) | 597 pyauto.PyUITest.__init__(self, methodName, **kwargs) |
545 YoutubeTestHelper.__init__(self, self) | 598 YoutubeTestHelper.__init__(self, self) |
546 | 599 |
547 def _VerifyVideoTotalBytes(self): | 600 def _VerifyVideoTotalBytes(self): |
548 """Returns true if video total bytes information is available.""" | 601 """Returns true if video total bytes information is available.""" |
549 return self.GetVideoTotalBytes() > 0 | 602 return self.GetVideoTotalBytes() > 0 |
(...skipping 21 matching lines...) Expand all Loading... | |
571 self.PauseVideo() | 624 self.PauseVideo() |
572 # Wait for the video to finish loading. | 625 # Wait for the video to finish loading. |
573 while total_video_bytes > loaded_video_bytes: | 626 while total_video_bytes > loaded_video_bytes: |
574 loaded_video_bytes = self.GetVideoLoadedBytes() | 627 loaded_video_bytes = self.GetVideoLoadedBytes() |
575 time.sleep(1) | 628 time.sleep(1) |
576 self.PlayVideo() | 629 self.PlayVideo() |
577 # 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. |
578 time.sleep(10) | 631 time.sleep(10) |
579 | 632 |
580 def testYoutubeDroppedFrames(self): | 633 def testYoutubeDroppedFrames(self): |
581 """Measures the Youtube video dropped frames. Runs for 60 secs.""" | 634 """Measures the Youtube video dropped frames. Runs for 60 secs.""" |
dennis_jeffrey
2011/11/21 22:45:10
Clarify that this test measures the dropped frames
rohitbm
2011/11/22 00:57:09
Done.
| |
582 self.StartVideoForPerformance() | 635 self.StartVideoForPerformance() |
583 init_dropped_frames = self.GetVideoDroppedFrames() | 636 init_dropped_frames = self.GetVideoDroppedFrames() |
584 total_dropped_frames = 0 | 637 total_dropped_frames = 0 |
585 dropped_fps = [] | 638 dropped_fps = [] |
586 for _ in xrange(60): | 639 for _ in xrange(60): |
587 frames = self.GetVideoDroppedFrames() - init_dropped_frames | 640 frames = self.GetVideoDroppedFrames() - init_dropped_frames |
588 current_dropped_frames = frames - total_dropped_frames | 641 current_dropped_frames = frames - total_dropped_frames |
589 dropped_fps.append(current_dropped_frames) | 642 dropped_fps.append(current_dropped_frames) |
590 total_dropped_frames = frames | 643 total_dropped_frames = frames |
591 # Play the video for some time | 644 # Play the video for some time |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1344 """Identifies the port number to which the server is currently bound. | 1397 """Identifies the port number to which the server is currently bound. |
1345 | 1398 |
1346 Returns: | 1399 Returns: |
1347 The numeric port number to which the server is currently bound. | 1400 The numeric port number to which the server is currently bound. |
1348 """ | 1401 """ |
1349 return self._server.server_address[1] | 1402 return self._server.server_address[1] |
1350 | 1403 |
1351 | 1404 |
1352 if __name__ == '__main__': | 1405 if __name__ == '__main__': |
1353 pyauto_functional.Main() | 1406 pyauto_functional.Main() |
OLD | NEW |