From f2a30da11d3fc87d2d371098bb308c0998fedbfe Mon Sep 17 00:00:00 2001 From: "dennisjeffrey@chromium.org" Date: Wed, 23 Nov 2011 00:01:30 +0000 Subject: Adding a short-running pyauto-based Angry Birds performance test to perf.py. The test loads the Angry Birds webapp, lets it run for a minute, then measures CPU utilization and v8 heap size. BUG=chromium-os:23230 TEST=None Review URL: http://codereview.chromium.org/8566053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111258 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/test/functional/perf.py | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'chrome/test/functional') diff --git a/chrome/test/functional/perf.py b/chrome/test/functional/perf.py index 411c1d7..dd0d778 100644 --- a/chrome/test/functional/perf.py +++ b/chrome/test/functional/perf.py @@ -1171,6 +1171,66 @@ class FlashTest(BasePerfTest): '%s_ScimarkGui-%s-Mem' % ('MB', benchmark), mem) +class LiveGamePerfTest(BasePerfTest): + """Tests to measure performance of live gaming webapps.""" + + def ExtraChromeFlags(self): + """Ensures Chrome is launched with custom flags. + + Returns: + A list of extra flags to pass to Chrome when it is launched. + """ + # Ensure Chrome enables remote debugging on port 9222. This is required to + # take v8 heap snapshots of tabs in Chrome. + return (super(LiveGamePerfTest, self).ExtraChromeFlags() + + ['--remote-debugging-port=9222']) + + def _RunLiveGamePerfTest(self, url, url_title_substring, + description): + """Measures performance metrics for the specified live gaming webapp. + + This function connects to the specified URL to launch the gaming webapp, + waits for a period of time for the webapp to run, then collects some + performance metrics about the running webapp. + + Args: + url: The string URL of the gaming webapp to analyze. + url_title_substring: A string that is expected to be a substring of the + webpage title for the specified gaming webapp. Used + to verify that the webapp loads correctly. + description: A string description for this game, used in the performance + value description. Should not contain any spaces. + """ + self.NavigateToURL(url) + loaded_tab_title = self.GetActiveTabTitle() + self.assertTrue(url_title_substring in loaded_tab_title, + msg='Loaded tab title missing "%s": "%s"' % + (url_title_substring, loaded_tab_title)) + cpu_usage_start = self._GetCPUUsage() + + # Let the app run for 1 minute. + time.sleep(60) + + cpu_usage_end = self._GetCPUUsage() + fraction_non_idle_time = self._GetFractionNonIdleCPUTime( + cpu_usage_start, cpu_usage_end) + + logging.info('Fraction of CPU time spent non-idle: %.2f' % + fraction_non_idle_time) + self._OutputPerfGraphValue('Fraction_%sCpuBusy' % description, + fraction_non_idle_time) + snapshotter = perf_snapshot.PerformanceSnapshotter() + snapshot = snapshotter.HeapSnapshot()[0] + v8_heap_size = snapshot['total_heap_size'] / (1024.0 * 1024.0) + logging.info('Total v8 heap size: %.2f MB' % v8_heap_size) + self._OutputPerfGraphValue('MB_%sV8HeapSize' % description, v8_heap_size) + + def testAngryBirds(self): + """Measures performance for Angry Birds.""" + self._RunLiveGamePerfTest('http://chrome.angrybirds.com', 'Angry Birds', + 'AngryBirds') + + class PerfTestServerRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): """Request handler for the local performance test server.""" -- cgit v1.1