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_pattern = 'Total:\s*([\d.]+)ms' | |
290 total = re.search(total_pattern, results).group(1) | |
Nirnimesh
2011/10/28 07:36:49
merge with previous line
dennis_jeffrey
2011/10/28 22:29:41
Done.
| |
291 logging.info('Total: %.2f ms' % float(total)) | |
292 self._OutputPerfGraphValue('%s_%s' % ('ms', 'SunSpider-total'), | |
Nirnimesh
2011/10/28 07:36:49
why not use 'ms_SunSpider-total' directly?
dennis_jeffrey
2011/10/28 22:29:41
Done.
| |
293 float(total)) | |
294 | |
295 category_pattern = '\s\s(\w+):.+?<br><br>' | |
296 result_pattern = '<br>\s\s\s\s([\w-]+):\s*([\d.]+)ms' | |
297 for match_category in re.finditer(category_pattern, results): | |
298 category_name = match_category.group(1) | |
299 for match_result in re.finditer(result_pattern, match_category.group(0)): | |
300 result_name = match_result.group(1) | |
301 result_value = match_result.group(2) | |
302 logging.info('Result %s-%s: %.2f ms', category_name, result_name, | |
303 float(result_value)) | |
304 self._OutputPerfGraphValue( | |
305 '%s_%s-%s-%s' % ('ms', 'SunSpider', category_name, result_name), | |
Nirnimesh
2011/10/28 07:36:49
Include ms_Sunspider in the format itself.
dennis_jeffrey
2011/10/28 22:29:41
Done.
| |
306 float(result_value)) | |
307 | |
265 | 308 |
266 class LiveWebappLoadTest(BasePerfTest): | 309 class LiveWebappLoadTest(BasePerfTest): |
267 """Tests that involve performance measurements of live webapps. | 310 """Tests that involve performance measurements of live webapps. |
268 | 311 |
269 These tests connect to live webpages (e.g., Gmail, Calendar, Docs) and are | 312 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 | 313 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 | 314 "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. | 315 user's perspective), and are not expected to be precise. |
273 """ | 316 """ |
274 | 317 |
(...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. | 954 """Identifies the port number to which the server is currently bound. |
912 | 955 |
913 Returns: | 956 Returns: |
914 The numeric port number to which the server is currently bound. | 957 The numeric port number to which the server is currently bound. |
915 """ | 958 """ |
916 return self._server.server_address[1] | 959 return self._server.server_address[1] |
917 | 960 |
918 | 961 |
919 if __name__ == '__main__': | 962 if __name__ == '__main__': |
920 pyauto_functional.Main() | 963 pyauto_functional.Main() |
OLD | NEW |