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

Side by Side Diff: chrome/test/functional/media/media_fps_perf.py

Issue 9464004: Fix CPU and memory perf PyAuto test running on av_perf. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Run each video once. Created 8 years, 9 months 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
OLDNEW
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 """FPS (frames per second) performance test for <video>. 6 """CPU, Memory, and FPS performance test for <video>.
7 7
8 Calculates decoded fps and dropped fps while playing HTML5 media element. The 8 Calculates decoded fps, dropped fps, CPU, and memory statistics while playing
9 test compares results of playing a media file on different video resolutions. 9 HTML5 media element. The test compares results of playing a media file on
10 different video resolutions.
10 """ 11 """
11 12
12 import logging 13 import logging
13 import os 14 import os
15 import psutil
14 16
15 import pyauto_media 17 import pyauto_media
16 import pyauto 18 import pyauto
17 import pyauto_utils 19 import pyauto_utils
18 20
19 # HTML test path; relative to src/chrome/test/data. 21 # HTML test path; relative to src/chrome/test/data.
20 _TEST_HTML_PATH = os.path.join('media', 'html', 'media_fps_perf.html') 22 _TEST_HTML_PATH = os.path.join('media', 'html', 'media_fps_perf.html')
21 23
22 # Path under data path for test files. 24 # Path under data path for test files.
23 _TEST_MEDIA_PATH = os.path.join('pyauto_private', 'media', 'crowd') 25 _TEST_MEDIA_PATH = os.path.join('pyauto_private', 'media', 'crowd')
24 26
25 # The media files used for testing. The map is from the media file type to short 27 # The media files used for testing.
26 # file names. A perf graph is generated for each file type. 28 _TEST_VIDEOS = [
27 _TEST_VIDEOS = { 29 'crowd2160.webm', 'crowd1080.webm', 'crowd720.webm', 'crowd480.webm',
28 'webm': ['crowd2160', 'crowd1080', 'crowd720', 'crowd480', 'crowd360'] 30 'crowd360.webm']
29 }
30 31
31 32
32 def ToMbit(value): 33 class MediaStatsPerfTest(pyauto.PyUITest):
33 """Converts a value of byte per sec units into Mbps units."""
34 return float(value * 8) / (1024 * 1024)
35
36
37 class MediaFPSPerfTest(pyauto.PyUITest):
38 """PyAuto test container. See file doc string for more information.""" 34 """PyAuto test container. See file doc string for more information."""
39 35
40 def testMediaFPSPerformance(self): 36 def _GetChromeRendererProcess(self):
41 """Launches HTML test which plays each video and records statistics. 37 """Returns the Chrome renderer process."""
38 renderer_id = self.GetBrowserInfo()['windows'][0]['tabs'][1]['renderer_pid']
39 if not renderer_id:
40 self.fail('Can not find the tab renderer process.')
41 return psutil.Process(renderer_id)
42 42
43 For each video, the test plays till ended event is fired. It records decoded 43 def testMediaPerformance(self):
44 fps, dropped fps, and total dropped frames. 44 """Launches HTML test which plays each video and records statistics."""
45 """ 45 for file_name in _TEST_VIDEOS:
46 self.NavigateToURL(self.GetFileURLForDataPath(_TEST_HTML_PATH)) 46 # Append a tab and delete it at the end of the test to free its memory.
47 self.AppendTab(pyauto.GURL(self.GetFileURLForDataPath(_TEST_HTML_PATH)))
47 48
48 for ext, files in _TEST_VIDEOS.iteritems(): 49 file_url = self.GetFileURLForDataPath(
49 for name in files: 50 os.path.join(_TEST_MEDIA_PATH, '%s' % file_name))
DaleCurtis 2012/03/01 02:47:11 Just file_name without %
shadi 2012/03/01 19:17:33 Done.
50 file_url = self.GetFileURLForDataPath( 51 logging.debug('Running perf test for %s.', file_url)
51 os.path.join(_TEST_MEDIA_PATH, '%s.%s' % (name, ext)))
52 logging.debug('Running fps perf test for %s.', file_url)
53 self.assertTrue(self.ExecuteJavascript("startTest('%s');" % file_url))
54 decoded_fps = [float(value) for value in
55 self.GetDOMValue("decodedFPS.join(',')").split(',')]
56 dropped_frames = self.GetDOMValue('droppedFrames')
57 dropped_fps = [float(value) for value in
58 self.GetDOMValue("droppedFPS.join(',')").split(',')]
59 52
60 pyauto_utils.PrintPerfResult('FPS_' + ext, name, decoded_fps, 'fps') 53 renderer_process = self._GetChromeRendererProcess()
61 pyauto_utils.PrintPerfResult('Dropped_FPS_' + ext, name, dropped_fps, 54 # Call to set a starting time to record CPU usage by the renderer.
62 'fps') 55 renderer_process.get_cpu_percent()
63 pyauto_utils.PrintPerfResult('Dropped_Frames_' + ext, name, 56
64 dropped_frames, 'frames') 57 self.assertTrue(
58 self.CallJavascriptFunc('startTest', [file_url, True], tab_index=1))
59
60 cpu_usage = renderer_process.get_cpu_percent()
61 mem_usage = renderer_process.get_memory_info()[0] / 1024
62 pyauto_utils.PrintPerfResult('cpu', file_name, cpu_usage, '%')
63 pyauto_utils.PrintPerfResult('memory', file_name, mem_usage, 'KB')
64
65 decoded_fps = [
66 float(value) for value in
67 self.GetDOMValue("decodedFPS.join(',')", tab_index=1).split(',')]
68 dropped_frames = self.GetDOMValue('droppedFrames', tab_index=1)
69 dropped_fps = [
70 float(value) for value in
71 self.GetDOMValue("droppedFPS.join(',')", tab_index=1).split(',')]
72
73 pyauto_utils.PrintPerfResult('fps', file_name, decoded_fps, 'fps')
DaleCurtis 2012/03/01 02:47:11 Will we need to clean up the old graphs on the bot
shadi 2012/03/01 19:17:33 I think they are automatically cleaned up after wh
74 pyauto_utils.PrintPerfResult('dropped_fps', file_name, dropped_fps, 'fps')
75 pyauto_utils.PrintPerfResult('dropped_frames', file_name, dropped_frames,
76 'frames')
77
78 self.GetBrowserWindow(0).GetTab(1).Close(True)
65 79
66 80
67 if __name__ == '__main__': 81 if __name__ == '__main__':
68 pyauto_media.Main() 82 pyauto_media.Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698