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

Side by Side Diff: tools/perf/benchmarks/sunspider.py

Issue 17438002: [telemetry] test_runner and run_benchmarks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update docs? Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/perf/benchmarks/smoothness.py ('k') | tools/perf/measurements/__init__.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4
5 """Runs Apple's SunSpider JavaScript benchmark."""
6
7 import collections 4 import collections
8 import json 5 import json
9 import os 6 import os
10 7
8 from telemetry import test
11 from telemetry.core import util 9 from telemetry.core import util
12 from telemetry.page import page_measurement 10 from telemetry.page import page_measurement
13 from telemetry.page import page_set 11 from telemetry.page import page_set
14 12
15 class SunSpiderMeasurement(page_measurement.PageMeasurement):
16 def CreatePageSet(self, _, options):
17 return page_set.PageSet.FromDict({
18 'serving_dirs': ['../../../chrome/test/data/sunspider/'],
19 'pages': [
20 { 'url': 'file:///../../../chrome/test/data/sunspider/'
21 'sunspider-1.0/driver.html' }
22 ]
23 }, os.path.abspath(__file__))
24 13
14 class SunspiderMeasurement(page_measurement.PageMeasurement):
25 def MeasurePage(self, _, tab, results): 15 def MeasurePage(self, _, tab, results):
26 js_is_done = """ 16 js_is_done = 'window.location.pathname.indexOf("results.html") >= 0'
27 window.location.pathname.indexOf('results.html') >= 0"""
28 def _IsDone(): 17 def _IsDone():
29 return tab.EvaluateJavaScript(js_is_done) 18 return tab.EvaluateJavaScript(js_is_done)
30 util.WaitFor(_IsDone, 300, poll_interval=5) 19 util.WaitFor(_IsDone, 300, poll_interval=1)
31 20
32 js_get_results = 'JSON.stringify(output);' 21 js_get_results = 'JSON.stringify(output);'
33 js_results = json.loads(tab.EvaluateJavaScript(js_get_results)) 22 js_results = json.loads(tab.EvaluateJavaScript(js_get_results))
34 r = collections.defaultdict(list) 23 r = collections.defaultdict(list)
35 totals = [] 24 totals = []
36 # js_results is: [{'foo': v1, 'bar': v2}, 25 # js_results is: [{'foo': v1, 'bar': v2},
37 # {'foo': v3, 'bar': v4}, 26 # {'foo': v3, 'bar': v4},
38 # ...] 27 # ...]
39 for result in js_results: 28 for result in js_results:
40 total = 0 29 total = 0
41 for key, value in result.iteritems(): 30 for key, value in result.iteritems():
42 r[key].append(value) 31 r[key].append(value)
43 total += value 32 total += value
44 totals.append(total) 33 totals.append(total)
45 for key, values in r.iteritems(): 34 for key, values in r.iteritems():
46 results.Add(key, 'ms', values, data_type='unimportant') 35 results.Add(key, 'ms', values, data_type='unimportant')
47 results.Add('Total', 'ms', totals) 36 results.Add('Total', 'ms', totals)
37
38
39 class Sunspider(test.Test):
40 """Performance on Apple's SunSpider JavaScript benchmark"""
41 test = SunspiderMeasurement
42
43 def CreatePageSet(self, options):
44 sunspider_dir = os.path.join(util.GetChromiumSrcDir(),
45 'chrome', 'test', 'data', 'sunspider')
46 return page_set.PageSet.FromDict(
47 {
48 'serving_dirs': [''],
49 'pages': [{ 'url': 'file:///sunspider-1.0/driver.html' }],
50 },
51 sunspider_dir)
OLDNEW
« no previous file with comments | « tools/perf/benchmarks/smoothness.py ('k') | tools/perf/measurements/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698