OLD | NEW |
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 self._OutputPerfGraphValue('%s_%s' % ('score', 'V8Benchmark'), | 255 self._OutputPerfGraphValue('%s_%s' % ('score', 'V8Benchmark'), |
256 int(final_score)) | 256 int(final_score)) |
257 for match in re.finditer(score_pattern, results['all_results']): | 257 for match in re.finditer(score_pattern, results['all_results']): |
258 benchmark_name = match.group(1) | 258 benchmark_name = match.group(1) |
259 benchmark_score = match.group(2) | 259 benchmark_score = match.group(2) |
260 logging.info('Result %s: %s', benchmark_name, benchmark_score) | 260 logging.info('Result %s: %s', benchmark_name, benchmark_score) |
261 self._OutputPerfGraphValue( | 261 self._OutputPerfGraphValue( |
262 '%s_%s-%s' % ('score', 'V8Benchmark', benchmark_name), | 262 '%s_%s-%s' % ('score', 'V8Benchmark', benchmark_name), |
263 int(benchmark_score)) | 263 int(benchmark_score)) |
264 | 264 |
| 265 def testSunSpider(self): |
| 266 """Runs the SunSpider javascript benchmark suite.""" |
| 267 url = self.GetFileURLForDataPath('sunspider', 'sunspider-driver.html') |
| 268 self.assertTrue(self.AppendTab(pyauto.GURL(url)), |
| 269 msg='Failed to append tab for SunSpider benchmark suite.') |
| 270 |
| 271 js_is_done = """ |
| 272 var done = false; |
| 273 if (document.getElementById("console")) |
| 274 done = true; |
| 275 window.domAutomationController.send(JSON.stringify(done)); |
| 276 """ |
| 277 self.assertTrue( |
| 278 self.WaitUntil( |
| 279 lambda: self.ExecuteJavascript(js_is_done, tab_index=1) == 'true', |
| 280 timeout=300, retry_sleep=1), |
| 281 msg='Timed out when waiting for SunSpider benchmark score.') |
| 282 |
| 283 js_get_results = """ |
| 284 window.domAutomationController.send( |
| 285 document.getElementById("console").innerHTML); |
| 286 """ |
| 287 # Append '<br>' to the result to simplify regular expression matching. |
| 288 results = self.ExecuteJavascript(js_get_results, tab_index=1) + '<br>' |
| 289 total = re.search('Total:\s*([\d.]+)ms', results).group(1) |
| 290 logging.info('Total: %.2f ms' % float(total)) |
| 291 self._OutputPerfGraphValue('ms_SunSpider-total', float(total)) |
| 292 |
| 293 for match_category in re.finditer('\s\s(\w+):.+?<br><br>', results): |
| 294 category_name = match_category.group(1) |
| 295 for match_result in re.finditer('<br>\s\s\s\s([\w-]+):\s*([\d.]+)ms', |
| 296 match_category.group(0)): |
| 297 result_name = match_result.group(1) |
| 298 result_value = match_result.group(2) |
| 299 logging.info('Result %s-%s: %.2f ms', category_name, result_name, |
| 300 float(result_value)) |
| 301 self._OutputPerfGraphValue( |
| 302 'ms_SunSpider-%s-%s' % (category_name, result_name), |
| 303 float(result_value)) |
| 304 |
265 | 305 |
266 class LiveWebappLoadTest(BasePerfTest): | 306 class LiveWebappLoadTest(BasePerfTest): |
267 """Tests that involve performance measurements of live webapps. | 307 """Tests that involve performance measurements of live webapps. |
268 | 308 |
269 These tests connect to live webpages (e.g., Gmail, Calendar, Docs) and are | 309 These tests connect to live webpages (e.g., Gmail, Calendar, Docs) and are |
270 therefore subject to network conditions. These tests are meant to generate | 310 therefore subject to network conditions. These tests are meant to generate |
271 "ball-park" numbers only (to see roughly how long things take to occur from a | 311 "ball-park" numbers only (to see roughly how long things take to occur from a |
272 user's perspective), and are not expected to be precise. | 312 user's perspective), and are not expected to be precise. |
273 """ | 313 """ |
274 | 314 |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 """Identifies the port number to which the server is currently bound. | 951 """Identifies the port number to which the server is currently bound. |
912 | 952 |
913 Returns: | 953 Returns: |
914 The numeric port number to which the server is currently bound. | 954 The numeric port number to which the server is currently bound. |
915 """ | 955 """ |
916 return self._server.server_address[1] | 956 return self._server.server_address[1] |
917 | 957 |
918 | 958 |
919 if __name__ == '__main__': | 959 if __name__ == '__main__': |
920 pyauto_functional.Main() | 960 pyauto_functional.Main() |
OLD | NEW |