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

Unified Diff: chrome/test/functional/perf.py

Issue 8413026: Add pyauto-based perf test for the SunSpider benchmark suite. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/perf.py
diff --git a/chrome/test/functional/perf.py b/chrome/test/functional/perf.py
index 3af55c6d1a76988542f546e85db08877154514a6..66246d9ecf696b5dfd28662e9f9c44e903037930 100644
--- a/chrome/test/functional/perf.py
+++ b/chrome/test/functional/perf.py
@@ -262,6 +262,49 @@ class BenchmarkPerfTest(BasePerfTest):
'%s_%s-%s' % ('score', 'V8Benchmark', benchmark_name),
int(benchmark_score))
+ def testSunSpider(self):
+ """Runs the SunSpider javascript benchmark suite."""
+ url = self.GetFileURLForDataPath('sunspider', 'sunspider-driver.html')
+ self.assertTrue(self.AppendTab(pyauto.GURL(url)),
+ msg='Failed to append tab for SunSpider benchmark suite.')
+
+ js_is_done = """
+ var done = false;
+ if (document.getElementById("console"))
+ done = true;
+ window.domAutomationController.send(JSON.stringify(done));
+ """
+ self.assertTrue(
+ self.WaitUntil(
+ lambda: self.ExecuteJavascript(js_is_done, tab_index=1) == 'true',
+ timeout=300, retry_sleep=1),
+ msg='Timed out when waiting for SunSpider benchmark score.')
+
+ js_get_results = """
+ window.domAutomationController.send(
+ document.getElementById("console").innerHTML);
+ """
+ # Append '<br>' to the result to simplify regular expression matching.
+ results = self.ExecuteJavascript(js_get_results, tab_index=1) + '<br>'
+ total_pattern = 'Total:\s*([\d.]+)ms'
+ 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.
+ logging.info('Total: %.2f ms' % float(total))
+ 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.
+ float(total))
+
+ category_pattern = '\s\s(\w+):.+?<br><br>'
+ result_pattern = '<br>\s\s\s\s([\w-]+):\s*([\d.]+)ms'
+ for match_category in re.finditer(category_pattern, results):
+ category_name = match_category.group(1)
+ for match_result in re.finditer(result_pattern, match_category.group(0)):
+ result_name = match_result.group(1)
+ result_value = match_result.group(2)
+ logging.info('Result %s-%s: %.2f ms', category_name, result_name,
+ float(result_value))
+ self._OutputPerfGraphValue(
+ '%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.
+ float(result_value))
+
class LiveWebappLoadTest(BasePerfTest):
"""Tests that involve performance measurements of live webapps.
« 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