Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: functional/perf.py

Issue 8562006: Adding Netflix performance measurement tests for dropped frames and CPU extrapolation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« functional/netflix.py ('K') | « functional/netflix.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 import threading 34 import threading
35 import time 35 import time
36 import timeit 36 import timeit
37 import urllib 37 import urllib
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 from netflix import NetflixTestHelper
44 import perf_snapshot 45 import perf_snapshot
45 import pyauto_utils 46 import pyauto_utils
46 import test_utils 47 import test_utils
47 from youtube import YoutubeTestHelper 48 from youtube import YoutubeTestHelper
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
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/second. Runs for 60 secs."""
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 = \
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 * \
587 (total_video_frames + total_dropped_frames) / total_video_frames
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
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/second. Runs for 60 secs."""
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
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()
OLDNEW
« functional/netflix.py ('K') | « functional/netflix.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698