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

Side by Side Diff: chrome/test/functional/perf.py

Issue 8566053: Adding a short-running pyauto-based Angry Birds performance test to perf.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed first round of review comments. 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
« no previous file with comments | « no previous file | 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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 benchmark = benchmark[:benchmark.find('_mflops')] 1164 benchmark = benchmark[:benchmark.find('_mflops')]
1165 logging.info('Results for ScimarkGui_' + benchmark + ':') 1165 logging.info('Results for ScimarkGui_' + benchmark + ':')
1166 logging.info(' %.2f MFLOPS', mflops) 1166 logging.info(' %.2f MFLOPS', mflops)
1167 logging.info(' %.2f MB', mem) 1167 logging.info(' %.2f MB', mem)
1168 self._OutputPerfGraphValue( 1168 self._OutputPerfGraphValue(
1169 '%s_ScimarkGui-%s-MFLOPS' % ('MFLOPS', benchmark), mflops) 1169 '%s_ScimarkGui-%s-MFLOPS' % ('MFLOPS', benchmark), mflops)
1170 self._OutputPerfGraphValue( 1170 self._OutputPerfGraphValue(
1171 '%s_ScimarkGui-%s-Mem' % ('MB', benchmark), mem) 1171 '%s_ScimarkGui-%s-Mem' % ('MB', benchmark), mem)
1172 1172
1173 1173
1174 class LiveGamePerfTest(BasePerfTest):
1175 """Tests to measure performance of live gaming webapps."""
1176
1177 def ExtraChromeFlags(self):
1178 """Ensures Chrome is launched with custom flags.
1179
1180 Returns:
1181 A list of extra flags to pass to Chrome when it is launched.
1182 """
1183 # Ensure Chrome enables remote debugging on port 9222. This is required to
1184 # take v8 heap snapshots of tabs in Chrome.
1185 return (super(LiveGamePerfTest, self).ExtraChromeFlags() +
1186 ['--remote-debugging-port=9222'])
1187
1188 def _RunLiveGamePerfTest(self, url, url_title_substring,
1189 description):
1190 """Measures performance metrics for the specified live gaming webapp.
1191
1192 This function connects to the specified URL to launch the gaming webapp,
1193 waits for a period of time for the webapp to run, then collects some
1194 performance metrics about the running webapp.
1195
1196 Args:
1197 url: The string URL of the gaming webapp to analyze.
1198 url_title_substring: A string that is expected to be a substring of the
1199 webpage title for the specified gaming webapp. Used
1200 to verify that the webapp loads correctly.
1201 description: A string description for this game, used in the performance
1202 value description. Should not contain any spaces.
1203 """
1204 self.NavigateToURL(url)
1205 loaded_tab_title = self.GetActiveTabTitle()
1206 self.assertTrue(url_title_substring in loaded_tab_title,
1207 msg='Loaded tab title missing "%s": "%s"' %
1208 (url_title_substring, loaded_tab_title))
1209 cpu_usage_start = self._GetCPUUsage()
1210
1211 # Let the app run for 1 minute.
1212 time.sleep(60)
1213
1214 cpu_usage_end = self._GetCPUUsage()
1215 fraction_non_idle_time = self._GetFractionNonIdleCPUTime(
1216 cpu_usage_start, cpu_usage_end)
1217
1218 logging.info('Fraction of CPU time spent non-idle: %.2f' %
1219 fraction_non_idle_time)
1220 self._OutputPerfGraphValue('Fraction_%sCpuBusy' % description,
1221 fraction_non_idle_time)
1222 snapshotter = perf_snapshot.PerformanceSnapshotter()
1223 snapshot = snapshotter.HeapSnapshot()[0]
1224 v8_heap_size = snapshot['total_heap_size'] / (1024.0 * 1024.0)
1225 logging.info('Total v8 heap size: %.2f MB' % v8_heap_size)
1226 self._OutputPerfGraphValue('MB_%sV8HeapSize' % description, v8_heap_size)
1227
1228 def testAngryBirds(self):
1229 """Measures performance for Angry Birds."""
1230 self._RunLiveGamePerfTest('http://chrome.angrybirds.com', 'Angry Birds',
1231 'AngryBirds')
1232
1233
1174 class PerfTestServerRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): 1234 class PerfTestServerRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
1175 """Request handler for the local performance test server.""" 1235 """Request handler for the local performance test server."""
1176 1236
1177 def _IgnoreHandler(self, unused_args): 1237 def _IgnoreHandler(self, unused_args):
1178 """A GET request handler that simply replies with status code 200. 1238 """A GET request handler that simply replies with status code 200.
1179 1239
1180 Args: 1240 Args:
1181 unused_args: A dictionary of arguments for the current GET request. 1241 unused_args: A dictionary of arguments for the current GET request.
1182 The arguments are ignored. 1242 The arguments are ignored.
1183 """ 1243 """
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 """Identifies the port number to which the server is currently bound. 1457 """Identifies the port number to which the server is currently bound.
1398 1458
1399 Returns: 1459 Returns:
1400 The numeric port number to which the server is currently bound. 1460 The numeric port number to which the server is currently bound.
1401 """ 1461 """
1402 return self._server.server_address[1] 1462 return self._server.server_address[1]
1403 1463
1404 1464
1405 if __name__ == '__main__': 1465 if __name__ == '__main__':
1406 pyauto_functional.Main() 1466 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698