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

Side by Side Diff: chrome/test/functional/media/media_stat_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: Rename test files. 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
« no previous file with comments | « chrome/test/functional/media/media_fps_perf.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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 """CPU, Memory, and FPS performance test for <video>.
7
8 Calculates decoded fps, dropped fps, CPU, and memory statistics while playing
9 HTML5 media element. The test compares results of playing a media file on
10 different video resolutions.
11 """
12
13 import logging
14 import os
15 import psutil
16
17 import pyauto_media
18 import pyauto
19 import pyauto_utils
20
21 # HTML test path; relative to src/chrome/test/data.
22 _TEST_HTML_PATH = os.path.join('media', 'html', 'media_stat_perf.html')
23
24 # Path under data path for test files.
25 _TEST_MEDIA_PATH = os.path.join('pyauto_private', 'media', 'crowd')
26
27 # The media files used for testing.
28 _TEST_VIDEOS = [
29 'crowd2160.webm', 'crowd1080.webm', 'crowd720.webm', 'crowd480.webm',
30 'crowd360.webm']
31
32
33 class MediaStatsPerfTest(pyauto.PyUITest):
34 """PyAuto test container. See file doc string for more information."""
35
36 def _GetChromeRendererProcess(self):
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
43 def testMediaPerformance(self):
44 """Launches HTML test which plays each video and records statistics."""
45 for file_name in _TEST_VIDEOS:
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)))
48
49 file_url = self.GetFileURLForDataPath(
50 os.path.join(_TEST_MEDIA_PATH, file_name))
51 logging.debug('Running perf test for %s.', file_url)
52
53 renderer_process = self._GetChromeRendererProcess()
54 # Call to set a starting time to record CPU usage by the renderer.
55 renderer_process.get_cpu_percent()
56
57 self.assertTrue(
58 self.CallJavascriptFunc('startTest', [file_url], tab_index=1))
59
60 cpu_usage = renderer_process.get_cpu_percent()
61 mem_usage_mb = 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_mb, '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')
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)
79
80
81 if __name__ == '__main__':
82 pyauto_media.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/media/media_fps_perf.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698