OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 | 4 |
5 function ObjectWithKeys(count, keyOffset = 0, keyGen) { | 5 function ObjectWithKeys(count, keyOffset = 0, keyGen) { |
6 var o = {}; | 6 var o = {}; |
7 for (var i = 0; i < count; i++) { | 7 for (var i = 0; i < count; i++) { |
8 var key = keyGen(i + keyOffset); | 8 var key = keyGen(i + keyOffset); |
9 o[key] = "value"; | 9 o[key] = "value"; |
10 } | 10 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 function Internalize(s) { | 74 function Internalize(s) { |
75 return Object.keys({[s]:0})[0]; | 75 return Object.keys({[s]:0})[0]; |
76 } | 76 } |
77 | 77 |
78 function Deinternalize(s) { | 78 function Deinternalize(s) { |
79 return [...s].join(""); | 79 return [...s].join(""); |
80 } | 80 } |
81 | 81 |
82 // ============================================================================ | 82 // ============================================================================ |
83 | 83 |
84 const QUERY_INTERNALIZED_PROP = "query-internalized-prop"; | 84 const QUERY_INTERNALIZED_PROP = "INTERN-prop"; |
85 const QUERY_DEINTERNALIZED_PROP = "query-deinternalized-prop"; | 85 const QUERY_DEINTERNALIZED_PROP = "DEINTERN-prop"; |
86 const QUERY_NON_EXISTING_INTERNALIZED_PROP = | 86 const QUERY_NON_EXISTING_INTERNALIZED_PROP = "NE-INTERN-prop"; |
87 "query-non-existing-internalized-prop"; | 87 const QUERY_NON_EXISTING_DEINTERNALIZED_PROP = "NE-DEINTERN-prop"; |
88 const QUERY_NON_EXISTING_DEINTERNALIZED_PROP = | 88 const QUERY_ELEMENT = "el"; |
89 "query-non-existing-deinternalized-prop"; | 89 const QUERY_ELEMENT_AS_STRING = "el-str"; |
90 const QUERY_ELEMENT = "query-element"; | 90 const QUERY_NON_EXISTING_ELEMENT = "NE-el"; |
91 const QUERY_ELEMENT_AS_STRING = "query-element-as-string"; | |
92 const QUERY_NON_EXISTING_ELEMENT = "query-non-existing-element"; | |
93 | 91 |
94 const OBJ_MODE_FAST = "fast"; | 92 const OBJ_MODE_FAST = "fast"; |
95 const OBJ_MODE_SLOW = "slow"; | 93 const OBJ_MODE_SLOW = "slow"; |
96 | 94 |
97 var TestQueries = [ | 95 var TestQueries = [ |
98 QUERY_INTERNALIZED_PROP, | 96 QUERY_INTERNALIZED_PROP, |
99 QUERY_DEINTERNALIZED_PROP, | 97 QUERY_DEINTERNALIZED_PROP, |
100 QUERY_NON_EXISTING_INTERNALIZED_PROP, | 98 QUERY_NON_EXISTING_INTERNALIZED_PROP, |
101 QUERY_NON_EXISTING_DEINTERNALIZED_PROP, | 99 QUERY_NON_EXISTING_DEINTERNALIZED_PROP, |
102 QUERY_ELEMENT, | 100 QUERY_ELEMENT, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // ============================================================================ | 229 // ============================================================================ |
232 // Create the benchmark suites. We create a suite for each pair of the test | 230 // Create the benchmark suites. We create a suite for each pair of the test |
233 // functions above and query kind. Each suite contains benchmarks for each | 231 // functions above and query kind. Each suite contains benchmarks for each |
234 // object type. | 232 // object type. |
235 var Benchmarks = []; | 233 var Benchmarks = []; |
236 | 234 |
237 for (var test_function_desc of TestFunctions) { | 235 for (var test_function_desc of TestFunctions) { |
238 var test_function_name = test_function_desc.name; | 236 var test_function_name = test_function_desc.name; |
239 | 237 |
240 for (var query_kind of TestQueries) { | 238 for (var query_kind of TestQueries) { |
| 239 var benchmarks = []; |
| 240 var suit_name = test_function_name + "--" + query_kind; |
241 for (var test_data of TestData) { | 241 for (var test_data of TestData) { |
242 var benchmarks = []; | 242 var name = suit_name + "--" + test_data.name; |
243 var name = test_function_name + "--" + query_kind + "--" + test_data.name; | |
244 | 243 |
245 for (var object of test_data.objects) { | 244 for (var object of test_data.objects) { |
246 var keys = test_function_desc.keys(object); | 245 var keys = test_function_desc.keys(object); |
247 keys = MakeKeyQueries(keys, query_kind); | 246 keys = MakeKeyQueries(keys, query_kind); |
248 | 247 |
249 var test_function = CreateTestFunction(test_function_desc.template, | 248 var test_function = CreateTestFunction(test_function_desc.template, |
250 object, keys); | 249 object, keys); |
251 | 250 |
252 var benchmark = new Benchmark(name, false, true, 400, test_function); | 251 var benchmark = new Benchmark(name, false, true, 400, test_function); |
253 benchmarks.push(benchmark); | 252 benchmarks.push(benchmark); |
254 } | 253 } |
255 Benchmarks.push(new BenchmarkSuite(name, [100], benchmarks)); | |
256 } | 254 } |
| 255 Benchmarks.push(new BenchmarkSuite(suit_name, [100], benchmarks)); |
257 } | 256 } |
258 } | 257 } |
259 | 258 |
260 // ============================================================================ | 259 // ============================================================================ |
OLD | NEW |