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

Unified Diff: chrome/test/functional/media/media_cpu_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: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/media/html/media_cpu_perf.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/media/media_cpu_perf.py
diff --git a/chrome/test/functional/media/media_cpu_perf.py b/chrome/test/functional/media/media_cpu_perf.py
new file mode 100644
index 0000000000000000000000000000000000000000..98c15522c1249dd7ba8040bc6b2756df01abb778
--- /dev/null
+++ b/chrome/test/functional/media/media_cpu_perf.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""CPU and memory test performance for <video>.
+
+Calculates CPU and memory statistics while playing videos with different
+resolutions.
+"""
+
+import logging
+import os
+import psutil
+
+import pyauto_media
+import pyauto
+import pyauto_utils
+
+# HTML test path; relative to src/chrome/test/data.
+_TEST_HTML_PATH = os.path.join('media', 'html', 'media_cpu_perf.html')
+
+# Path under data path for test files.
+_TEST_MEDIA_PATH = os.path.join('pyauto_private', 'media', 'crowd')
+
+# The media files used for testing. The map is from the media file type to short
+# file names. A perf graph is generated for each file type.
+_TEST_VIDEOS = {
+ 'webm': ['crowd2160', 'crowd1080', 'crowd720', 'crowd480', 'crowd360']
+}
+
+
+class MediaFPSPerfTest(pyauto.PyUITest):
DaleCurtis 2012/02/24 17:02:24 CPUTest?
+ """PyAuto test container. See file doc string for more information."""
+
+ def _GetChromeRendererProcess(self):
+ """Returns the Chrome renderer process."""
+ renderer_id = self.GetBrowserInfo()['windows'][0]['tabs'][1]['renderer_pid']
+ if not renderer_id:
+ self.fail('Can not find the tab renderer process.')
+ return psutil.Process(renderer_id)
+
+ def testMediaCPUandMemoryPerformance(self):
+ """Launches HTML test which plays each video and records CPU usage.
+
+ For each video, the test plays the video and records percentage of
+ CPU and memory used by the chrome renderer process.
+ """
+ for ext, files in _TEST_VIDEOS.iteritems():
+ for name in files:
+ # Append a tab and delete it at the end of the test to free its memory.
+ self.AppendTab(pyauto.GURL(self.GetFileURLForDataPath(_TEST_HTML_PATH)))
+
+ renderer_process = self._GetChromeRendererProcess()
+ file_url = self.GetFileURLForDataPath(
+ os.path.join(_TEST_MEDIA_PATH, '%s.%s' % (name, ext)))
+ logging.debug('Running CPU perf test for %s.', file_url)
+
+ # Call to set a starting time to record CPU usage by the renderer.
+ renderer_process.get_cpu_percent()
+
+ self.assertTrue(
+ self.CallJavascriptFunc('startTest', [file_url], tab_index=1))
+ cpu_usage = renderer_process.get_cpu_percent()
+ mem_usage = renderer_process.get_memory_info()[0] / 1024
+ pyauto_utils.PrintPerfResult('CPU_' + ext, name, cpu_usage, '%')
+ pyauto_utils.PrintPerfResult('Memory_' + ext, name, mem_usage, 'KB')
+
+ self.GetBrowserWindow(0).GetTab(1).Close(True)
+
+
+if __name__ == '__main__':
+ pyauto_media.Main()
« no previous file with comments | « chrome/test/data/media/html/media_cpu_perf.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698