| OLD | NEW |
| (Empty) |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 import collections | |
| 5 import json | |
| 6 import os | |
| 7 | |
| 8 from core import perf_benchmark | |
| 9 | |
| 10 from telemetry import benchmark | |
| 11 from telemetry import page as page_module | |
| 12 from telemetry.page import legacy_page_test | |
| 13 from telemetry import story | |
| 14 from telemetry.value import list_of_scalar_values | |
| 15 | |
| 16 from metrics import power | |
| 17 | |
| 18 | |
| 19 _URL = 'http://www.webkit.org/perf/sunspider-1.0.2/sunspider-1.0.2/driver.html' | |
| 20 | |
| 21 DESCRIPTIONS = { | |
| 22 '3d-cube': | |
| 23 'Pure JavaScript computations of the kind you might use to do 3d ' | |
| 24 'rendering, but without the rendering. This ends up mostly hitting ' | |
| 25 'floating point math and array access.', | |
| 26 '3d-morph': | |
| 27 'Pure JavaScript computations of the kind you might use to do 3d ' | |
| 28 'rendering, but without the rendering. This ends up mostly hitting ' | |
| 29 'floating point math and array access.', | |
| 30 '3d-raytrace': | |
| 31 'Pure JavaScript computations of the kind you might use to do 3d ' | |
| 32 'rendering, but without the rendering. This ends up mostly hitting ' | |
| 33 'floating point math and array access.', | |
| 34 'access-binary-trees': 'Array, object property and variable access.', | |
| 35 'access-fannkuch': 'Array, object property and variable access.', | |
| 36 'access-nbody': 'Array, object property and variable access.', | |
| 37 'access-nsieve': 'Array, object property and variable access.', | |
| 38 'bitops-3bit-bits-in-byte': | |
| 39 'Bitwise operations, these can be useful for various things ' | |
| 40 'including games, mathematical computations, and various kinds of ' | |
| 41 'encoding/decoding. It\'s also the only kind of math in JavaScript ' | |
| 42 'that is done as integer, not floating point.', | |
| 43 'bitops-bits-in-byte': | |
| 44 'Bitwise operations, these can be useful for various things ' | |
| 45 'including games, mathematical computations, and various kinds of ' | |
| 46 'encoding/decoding. It\'s also the only kind of math in JavaScript ' | |
| 47 'that is done as integer, not floating point.', | |
| 48 'bitops-bitwise-and': | |
| 49 'Bitwise operations, these can be useful for various things ' | |
| 50 'including games, mathematical computations, and various kinds of ' | |
| 51 'encoding/decoding. It\'s also the only kind of math in JavaScript ' | |
| 52 'that is done as integer, not floating point.', | |
| 53 'bitops-nsieve-bits': | |
| 54 'Bitwise operations, these can be useful for various things ' | |
| 55 'including games, mathematical computations, and various kinds of ' | |
| 56 'encoding/decoding. It\'s also the only kind of math in JavaScript ' | |
| 57 'that is done as integer, not floating point.', | |
| 58 'controlflow-recursive': | |
| 59 'Control flow constructs (looping, recursion, conditionals). Right ' | |
| 60 'now it mostly covers recursion, as the others are pretty well covered ' | |
| 61 'by other tests.', | |
| 62 'crypto-aes': 'Real cryptography code related to AES.', | |
| 63 'crypto-md5': 'Real cryptography code related to MD5.', | |
| 64 'crypto-sha1': 'Real cryptography code related to SHA1.', | |
| 65 'date-format-tofte': 'Performance of JavaScript\'s "date" objects.', | |
| 66 'date-format-xparb': 'Performance of JavaScript\'s "date" objects.', | |
| 67 'math-cordic': 'Various mathematical type computations.', | |
| 68 'math-partial-sums': 'Various mathematical type computations.', | |
| 69 'math-spectral-norm': 'Various mathematical type computations.', | |
| 70 'regexp-dna': 'Regular expressions performance.', | |
| 71 'string-base64': 'String processing.', | |
| 72 'string-fasta': 'String processing', | |
| 73 'string-tagcloud': 'String processing code to generate a giant "tagcloud".', | |
| 74 'string-unpack-code': 'String processing code to extracting compressed JS.', | |
| 75 'string-validate-input': 'String processing.', | |
| 76 } | |
| 77 | |
| 78 | |
| 79 class _SunspiderMeasurement(legacy_page_test.LegacyPageTest): | |
| 80 | |
| 81 def __init__(self): | |
| 82 super(_SunspiderMeasurement, self).__init__() | |
| 83 self._power_metric = None | |
| 84 | |
| 85 def CustomizeBrowserOptions(self, options): | |
| 86 power.PowerMetric.CustomizeBrowserOptions(options) | |
| 87 | |
| 88 def WillStartBrowser(self, platform): | |
| 89 self._power_metric = power.PowerMetric(platform) | |
| 90 | |
| 91 def DidNavigateToPage(self, page, tab): | |
| 92 self._power_metric.Start(page, tab) | |
| 93 | |
| 94 def ValidateAndMeasurePage(self, page, tab, results): | |
| 95 tab.WaitForJavaScriptCondition( | |
| 96 'window.location.pathname.indexOf("results.html") >= 0' | |
| 97 '&& typeof(output) != "undefined"', timeout=300) | |
| 98 | |
| 99 self._power_metric.Stop(page, tab) | |
| 100 self._power_metric.AddResults(tab, results) | |
| 101 | |
| 102 js_results = json.loads(tab.EvaluateJavaScript('JSON.stringify(output);')) | |
| 103 | |
| 104 # Below, r is a map of benchmark names to lists of result numbers, | |
| 105 # and totals is a list of totals of result numbers. | |
| 106 # js_results is: formatted like this: | |
| 107 # [ | |
| 108 # {'3d-cube': v1, '3d-morph': v2, ...}, | |
| 109 # {'3d-cube': v3, '3d-morph': v4, ...}, | |
| 110 # ... | |
| 111 # ] | |
| 112 r = collections.defaultdict(list) | |
| 113 totals = [] | |
| 114 for result in js_results: | |
| 115 total = 0 | |
| 116 for key, value in result.iteritems(): | |
| 117 r[key].append(value) | |
| 118 total += value | |
| 119 totals.append(total) | |
| 120 for key, values in r.iteritems(): | |
| 121 results.AddValue(list_of_scalar_values.ListOfScalarValues( | |
| 122 results.current_page, key, 'ms', values, important=False, | |
| 123 description=DESCRIPTIONS.get(key))) | |
| 124 results.AddValue(list_of_scalar_values.ListOfScalarValues( | |
| 125 results.current_page, 'Total', 'ms', totals, | |
| 126 description='Totals of run time for each different type of benchmark ' | |
| 127 'in sunspider')) | |
| 128 | |
| 129 | |
| 130 @benchmark.Disabled('all') # crbug.com/712208 | |
| 131 @benchmark.Owner(emails=['bmeurer@chromium.org', 'mvstanton@chromium.org']) | |
| 132 class Sunspider(perf_benchmark.PerfBenchmark): | |
| 133 """Apple's SunSpider JavaScript benchmark. | |
| 134 | |
| 135 http://www.webkit.org/perf/sunspider/sunspider.html | |
| 136 """ | |
| 137 test = _SunspiderMeasurement | |
| 138 | |
| 139 @classmethod | |
| 140 def Name(cls): | |
| 141 return 'sunspider' | |
| 142 | |
| 143 def CreateStorySet(self, options): | |
| 144 ps = story.StorySet( | |
| 145 archive_data_file='../page_sets/data/sunspider.json', | |
| 146 base_dir=os.path.dirname(os.path.abspath(__file__)), | |
| 147 cloud_storage_bucket=story.PARTNER_BUCKET) | |
| 148 ps.AddStory(page_module.Page( | |
| 149 _URL, ps, ps.base_dir, make_javascript_deterministic=False)) | |
| 150 return ps | |
| OLD | NEW |