diff options
author | Michaël Zasso <targos@protonmail.com> | 2019-03-12 09:01:49 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-03-14 18:49:21 +0100 |
commit | 7b48713334469818661fe276cf571de9c7899f2d (patch) | |
tree | 4dbda49ac88db76ce09dc330a0cb587e68e139ba /deps/v8/test/js-perf-test | |
parent | 8549ac09b256666cf5275224ec58fab9939ff32e (diff) | |
download | android-node-v8-7b48713334469818661fe276cf571de9c7899f2d.tar.gz android-node-v8-7b48713334469818661fe276cf571de9c7899f2d.tar.bz2 android-node-v8-7b48713334469818661fe276cf571de9c7899f2d.zip |
deps: update V8 to 7.3.492.25
PR-URL: https://github.com/nodejs/node/pull/25852
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Diffstat (limited to 'deps/v8/test/js-perf-test')
37 files changed, 1733 insertions, 73 deletions
diff --git a/deps/v8/test/js-perf-test/Array/from.js b/deps/v8/test/js-perf-test/Array/from.js index 06e00a223e..d173c5af20 100644 --- a/deps/v8/test/js-perf-test/Array/from.js +++ b/deps/v8/test/js-perf-test/Array/from.js @@ -4,16 +4,26 @@ (() => { createSuite('MixedFrom', 1000, MixedFrom, MixedFromSetup); + createSuite( + 'MixedCowNoMapFrom', 1000, MixedCowNoMapFrom, MixedCowNoMapFromSetup); + createSuite('MixedNonCowNoMapFrom', 1000, MixedNonCowNoMapFrom, + MixedNonCowNoMapFromSetup); createSuite('SmiFrom', 1000, SmiFrom, SmiFromSetup); createSuite('SmallSmiFrom', 1000, SmallSmiFrom, SmallSmiFromSetup); - createSuite('SmiNoMapFrom', 1000, SmiNoMapFrom, SmiNoMapFromSetup); + createSuite('SmiCowNoMapFrom', 1000, SmiCowNoMapFrom, SmiCowNoMapFromSetup); + createSuite( + 'SmiNonCowNoMapFrom', 1000, SmiNonCowNoMapFrom, SmiNonCowNoMapFromSetup); createSuite( 'SmiNoIteratorFrom', 1000, SmiNoIteratorFrom, SmiNoIteratorFromSetup); createSuite( 'TransplantedFrom', 1000, TransplantedFrom, TransplantedFromSetup); createSuite('DoubleFrom', 1000, DoubleFrom, DoubleFromSetup); + createSuite('DoubleNoMapFrom', 1000, DoubleNoMapFrom, DoubleNoMapFromSetup); createSuite('StringFrom', 1000, StringFrom, StringFromSetup); - createSuite('StringNoMapFrom', 1000, StringNoMapFrom, StringNoMapFromSetup); + createSuite( + 'StringCowNoMapFrom', 1000, StringCowNoMapFrom, StringCowNoMapFromSetup); + createSuite('StringNonCowNoMapFrom', 1000, StringNonCowNoMapFrom, + StringNonCowNoMapFromSetup); function ArrayLike() {} ArrayLike.from = Array.from; @@ -22,7 +32,9 @@ var result; var func - var smi_array = [ + // This creates a COW array of smis. COWness does not affect the performance + // of Array.from calls with a callback function. + var smi_array_Cow = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, @@ -30,6 +42,11 @@ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ]; + // This creates a non-COW array. + var smi_array = Array.from(smi_array_Cow); + smi_array[0] = 1; + + // This creates an array of doubles. There is no COW array for doubles. var double_array = [ 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, // 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, @@ -43,7 +60,8 @@ 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, ]; - var string_array = [ + // This creates a COW array of objects. + var string_array_Cow = [ 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'a', 'b', 'c', 'a', 'b', @@ -53,7 +71,12 @@ 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', ]; - var mixed_array = [ + // This creates a non-COW array. + var string_array = Array.from(string_array_Cow); + string_array[0] = 'a'; + + // This creates a COW array of objects. + var mixed_array_Cow = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, // 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, @@ -66,13 +89,21 @@ 'a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a', ]; + // This creates a non-COW array. + var mixed_array = Array.from(mixed_array_Cow); + mixed_array[0] = 1; + // Although these functions have the same code, they are separated for // clean IC feedback. function SmallSmiFrom() { result = Array.from(arg, func); } - function SmiNoMapFrom() { + function SmiCowNoMapFrom() { + result = Array.from(arg); + } + + function SmiNonCowNoMapFrom() { result = Array.from(arg); } @@ -92,11 +123,19 @@ result = Array.from(arg, func); } + function DoubleNoMapFrom() { + result = Array.from(arg); + } + function StringFrom() { result = Array.from(arg, func); } - function StringNoMapFrom() { + function StringCowNoMapFrom() { + result = Array.from(arg); + } + + function StringNonCowNoMapFrom() { result = Array.from(arg); } @@ -104,31 +143,44 @@ result = Array.from(arg, func); } + function MixedCowNoMapFrom() { + result = Array.from(arg); + } + + function MixedNonCowNoMapFrom() { + result = Array.from(arg); + } + function SmallSmiFromSetup() { func = (v, i) => v + i; arg = [1, 2, 3]; } - function SmiNoMapFromSetup() { + function SmiCowNoMapFromSetup() { + func = undefined; + arg = smi_array_Cow; + } + + function SmiNonCowNoMapFromSetup() { func = undefined; arg = smi_array; } function SmiFromSetup() { func = (v, i) => v + i; - arg = smi_array; + arg = smi_array_Cow; } function SmiNoIteratorFromSetup() { func = (v, i) => v + i; - array = smi_array; + array = smi_array_Cow; arg = {length: array.length}; Object.assign(arg, array); } function TransplantedFromSetup() { func = (v, i) => v + i; - arg = smi_array; + arg = smi_array_Cow; } function DoubleFromSetup() { @@ -136,19 +188,38 @@ arg = double_array; } + function DoubleNoMapFromSetup() { + func = undefined; + arg = double_array; + } + function StringFromSetup() { func = (v, i) => v + i; - arg = string_array; + arg = string_array_Cow; } - function StringNoMapFromSetup() { + function StringCowNoMapFromSetup() { + func = undefined; + arg = string_array_Cow; + } + + function StringNonCowNoMapFromSetup() { func = undefined; arg = string_array; } function MixedFromSetup() { func = (v, i) => v + i; - arg = mixed_array; + arg = mixed_array_Cow; + } + + function MixedCowNoMapFromSetup() { + func = undefined; + arg = mixed_array_Cow; } + function MixedNonCowNoMapFromSetup() { + func = undefined; + arg = mixed_array; + } })(); diff --git a/deps/v8/test/js-perf-test/Array/reduce.js b/deps/v8/test/js-perf-test/Array/reduce.js index 2b9a28f098..3b07969669 100644 --- a/deps/v8/test/js-perf-test/Array/reduce.js +++ b/deps/v8/test/js-perf-test/Array/reduce.js @@ -6,7 +6,7 @@ // Make sure we inline the callback, pick up all possible TurboFan // optimizations. function RunOptFastReduce(multiple) { - // Use of variable multiple in the callback function forces + // Use of multiple variables in the callback function forces // context creation without escape analysis. // // Also, the arrow function requires inlining based on diff --git a/deps/v8/test/js-perf-test/ArrayIndexOfIncludesPolymorphic/indexof-includes-polymorphic.js b/deps/v8/test/js-perf-test/ArrayIndexOfIncludesPolymorphic/indexof-includes-polymorphic.js new file mode 100644 index 0000000000..c79ba71174 --- /dev/null +++ b/deps/v8/test/js-perf-test/ArrayIndexOfIncludesPolymorphic/indexof-includes-polymorphic.js @@ -0,0 +1,41 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function benchy(fn, name) { + new BenchmarkSuite(name, [1], [ + new Benchmark(name, true, false, 0, fn), + ]); +} + +function forLoop(array, searchValue) { + for (let i = 0; i < array.length; ++i) { + if (array[i] === searchValue) return true; + } + return farraylse; +} + +function indexOf(array, searchValue) { + return array.indexOf(searchValue) !== -1; +} + +function includes(array, searchValue) { + return array.includes(searchValue); +} + +const PACKED = [ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, +]; +const HOLEY = new Array(PACKED.length); +for (let i = 0; i < PACKED.length; ++i) + HOLEY[i] = PACKED[i]; + +function helper(fn) { + const SEARCH_VALUE = 15; + const result = fn(PACKED, SEARCH_VALUE) && fn(HOLEY, SEARCH_VALUE); + return result; +} + +benchy(() => helper(forLoop), 'for loop'); +benchy(() => helper(indexOf), 'Array#indexOf'); +benchy(() => helper(includes), 'Array#includes'); diff --git a/deps/v8/test/js-perf-test/ArrayIndexOfIncludesPolymorphic/run.js b/deps/v8/test/js-perf-test/ArrayIndexOfIncludesPolymorphic/run.js new file mode 100644 index 0000000000..3ad11b83e1 --- /dev/null +++ b/deps/v8/test/js-perf-test/ArrayIndexOfIncludesPolymorphic/run.js @@ -0,0 +1,23 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('../base.js'); +load(arguments[0] + '.js') + +function PrintResult(name, result) { + print(name + '-ArrayIndexOfIncludesPolymorphic(Score): ' + result); +} + +function PrintStep(name) {} + +function PrintError(name, error) { + PrintResult(name, error); +} + +BenchmarkSuite.config.doWarmup = undefined; +BenchmarkSuite.config.doDeterministic = undefined; + +BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, + NotifyError: PrintError, + NotifyStep: PrintStep }); diff --git a/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeDoubleHoley/run.js b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeDoubleHoley/run.js new file mode 100644 index 0000000000..72b83a3ada --- /dev/null +++ b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeDoubleHoley/run.js @@ -0,0 +1,158 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Comparing different copy schemes against spread initial literals. +// Benchmarks for large holey double arrays. + +const largeHoleyArray = new Array(1e5); + +for (var i = 0; i < 100; i++) { + largeHoleyArray[i] = i + 6.66; +} + +for (var i = 5000; i < 5500; i++) { + largeHoleyArray[i] = i + 6.66; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Spread +// ---------------------------------------------------------------------------- + +function SpreadLargeHoley() { + var newArr = [...largeHoleyArray]; + // basic sanity check + if (newArr.length != largeHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForLength +// ---------------------------------------------------------------------------- + +function ForLengthLargeHoley() { + var newArr = new Array(largeHoleyArray.length); + for (let i = 0; i < largeHoleyArray.length; i++) { + newArr[i] = largeHoleyArray[i]; + } + // basic sanity check + if (newArr.length != largeHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForLengthEmpty +// ---------------------------------------------------------------------------- + +function ForLengthEmptyLargeHoley() { + var newArr = []; + for (let i = 0; i < largeHoleyArray.length; i++) { + newArr[i] = largeHoleyArray[i]; + } + // basic sanity check + if (newArr.length != largeHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Slice +// ---------------------------------------------------------------------------- + +function SliceLargeHoley() { + var newArr = largeHoleyArray.slice(); + // basic sanity check + if (newArr.length != largeHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Slice0 +// ---------------------------------------------------------------------------- + +function Slice0LargeHoley() { + var newArr = largeHoleyArray.slice(0); + // basic sanity check + if (newArr.length != largeHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ConcatReceive +// ---------------------------------------------------------------------------- + +function ConcatReceiveLargeHoley() { + var newArr = largeHoleyArray.concat(); + // basic sanity check + if (newArr.length != largeHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ConcatArg +// ---------------------------------------------------------------------------- + +function ConcatArgLargeHoley() { + var newArr = [].concat(largeHoleyArray); + // basic sanity check + if (newArr.length != largeHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfPush +// ---------------------------------------------------------------------------- + +function ForOfPushLargeHoley() { + var newArr = []; + for (let x of largeHoleyArray) { + newArr.push(x) + } + // basic sanity check + if (newArr.length != largeHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: MapId +// ---------------------------------------------------------------------------- + +function MapIdLargeHoley() { + var newArr = largeHoleyArray.map(x => x); + // basic sanity check + if (newArr.length != largeHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Setup and Run +// ---------------------------------------------------------------------------- + +load('../base.js'); + +var success = true; + +function PrintResult(name, result) { + print(name + '-ArrayLiteralInitialSpreadLargeDoubleHoley(Score): ' + result); +} + +function PrintError(name, error) { + PrintResult('Error: ' + name, error); + success = false; +} + +// Run the benchmark (5 x 100) iterations instead of 1 second. +function CreateBenchmark(name, f) { + new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 5, f) ]); +} + +CreateBenchmark('Spread', SpreadLargeHoley); +CreateBenchmark('ForLength', ForLengthLargeHoley); +CreateBenchmark('ForLengthEmpty', ForLengthEmptyLargeHoley); +CreateBenchmark('Slice', SliceLargeHoley); +CreateBenchmark('Slice0', Slice0LargeHoley); +CreateBenchmark('ConcatReceive', ConcatReceiveLargeHoley); +CreateBenchmark('ConcatArg', ConcatArgLargeHoley); + +BenchmarkSuite.config.doWarmup = true; +BenchmarkSuite.config.doDeterministic = true; +BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError}); diff --git a/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeDoublePacked/run.js b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeDoublePacked/run.js new file mode 100644 index 0000000000..9b449840ea --- /dev/null +++ b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeDoublePacked/run.js @@ -0,0 +1,155 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Comparing different copy schemes against spread initial literals. +// Benchmarks for large packed double arrays. + +var largeArray = Array.from(Array(1e5).keys()); +// TODO(dhai): we should be able to use Array.prototype.map here, but that +// implementation is currently creating a HOLEY array. +for (var i = 0; i < 1e5; i++) { + largeArray[i] += 6.66; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Spread +// ---------------------------------------------------------------------------- + +function SpreadLarge() { + var newArr = [...largeArray]; + // basic sanity check + if (newArr.length != largeArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForLength +// ---------------------------------------------------------------------------- + +function ForLengthLarge() { + var newArr = new Array(largeArray.length); + for (let i = 0; i < largeArray.length; i++) { + newArr[i] = largeArray[i]; + } + // basic sanity check + if (newArr.length != largeArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForLengthEmpty +// ---------------------------------------------------------------------------- + +function ForLengthEmptyLarge() { + var newArr = []; + for (let i = 0; i < largeArray.length; i++) { + newArr[i] = largeArray[i]; + } + // basic sanity check + if (newArr.length != largeArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Slice +// ---------------------------------------------------------------------------- + +function SliceLarge() { + var newArr = largeArray.slice(); + // basic sanity check + if (newArr.length != largeArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Slice0 +// ---------------------------------------------------------------------------- + +function Slice0Large() { + var newArr = largeArray.slice(0); + // basic sanity check + if (newArr.length != largeArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ConcatReceive +// ---------------------------------------------------------------------------- + +function ConcatReceiveLarge() { + var newArr = largeArray.concat(); + // basic sanity check + if (newArr.length != largeArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ConcatArg +// ---------------------------------------------------------------------------- + +function ConcatArgLarge() { + var newArr = [].concat(largeArray); + // basic sanity check + if (newArr.length != largeArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfPush +// ---------------------------------------------------------------------------- + +function ForOfPushLarge() { + var newArr = []; + for (let x of largeArray) { + newArr.push(x) + } + // basic sanity check + if (newArr.length != largeArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: MapId +// ---------------------------------------------------------------------------- + +function MapIdLarge() { + var newArr = largeArray.map(x => x); + // basic sanity check + if (newArr.length != largeArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Setup and Run +// ---------------------------------------------------------------------------- + +load('../base.js'); + +var success = true; + +function PrintResult(name, result) { + print(name + '-ArrayLiteralInitialSpreadLargeDoublePacked(Score): ' + result); +} + +function PrintError(name, error) { + PrintResult('Error: ' + name, error); + success = false; +} + +// Run the benchmark (5 x 100) iterations instead of 1 second. +function CreateBenchmark(name, f) { + new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 5, f) ]); +} + +CreateBenchmark('Spread', SpreadLarge); +CreateBenchmark('ForLength', ForLengthLarge); +CreateBenchmark('ForLengthEmpty', ForLengthEmptyLarge); +CreateBenchmark('Slice', SliceLarge); +CreateBenchmark('Slice0', Slice0Large); +CreateBenchmark('ConcatReceive', ConcatReceiveLarge); +CreateBenchmark('ConcatArg', ConcatArgLarge); + +BenchmarkSuite.config.doWarmup = true; +BenchmarkSuite.config.doDeterministic = true; +BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError}); diff --git a/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargePacked/run.js b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargePacked/run.js index 38643c6903..dc279784cf 100644 --- a/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargePacked/run.js +++ b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargePacked/run.js @@ -5,8 +5,7 @@ // Comparing different copy schemes against spread initial literals. // Benchmarks for large packed arrays. -const largeHoleyArray = new Array(1e5); -const largeArray = Array.from(largeHoleyArray.keys()); +const largeArray = Array.from(Array(1e5).keys()); // ---------------------------------------------------------------------------- // Benchmark: Spread diff --git a/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeSmiMap/run.js b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeSmiMap/run.js new file mode 100644 index 0000000000..2654d53d9c --- /dev/null +++ b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeSmiMap/run.js @@ -0,0 +1,94 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Comparing different iterating schemes against spread initial literals. +// Benchmarks for large smi maps. + +var keys = Array.from(Array(1e4).keys()); +var keyValuePairs = keys.map((value) => [value, value + 1]); +var map = new Map(keyValuePairs); + +// ---------------------------------------------------------------------------- +// Benchmark: SpreadKeys +// ---------------------------------------------------------------------------- + +function SpreadKeys() { + var newArr = [...map.keys()]; + // basic sanity check + if (newArr.length != map.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: SpreadValues +// ---------------------------------------------------------------------------- + +function SpreadValues() { + var newArr = [...map.values()]; + // basic sanity check + if (newArr.length != map.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfKeys +// ---------------------------------------------------------------------------- + +function ForOfKeys() { + var newArr = new Array(map.size); + var i = 0; + for (let x of map.keys()) { + newArr[i] = x; + i++; + } + if (newArr.length != map.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfValues +// ---------------------------------------------------------------------------- + +function ForOfValues() { + var newArr = new Array(map.size); + var i = 0; + for (let x of map.values()) { + newArr[i] = x; + i++; + } + if (newArr.length != map.size) throw 666; + return newArr; +} + + +// ---------------------------------------------------------------------------- +// Setup and Run +// ---------------------------------------------------------------------------- + +load('../base.js'); + +var success = true; + +function PrintResult(name, result) { + print(name + '-ArrayLiteralInitialSpreadLargeSmiMap(Score): ' + result); +} + +function PrintError(name, error) { + PrintResult('Error: ' + name, error); + success = false; +} + +function CreateBenchmark(name, f) { + new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 0, f) ]); +} + +CreateBenchmark('ForOfKeys', ForOfKeys); +CreateBenchmark('ForOfValues', ForOfValues); +CreateBenchmark('SpreadKeys', SpreadKeys); +CreateBenchmark('SpreadValues', SpreadValues); + + +BenchmarkSuite.config.doWarmup = true; +BenchmarkSuite.config.doDeterministic = false; +BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError}); diff --git a/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeSmiSet/run.js b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeSmiSet/run.js new file mode 100644 index 0000000000..30a4a1666b --- /dev/null +++ b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadLargeSmiSet/run.js @@ -0,0 +1,121 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Comparing different iterating schemes against spread initial literals. +// Benchmarks for large smi sets. + +var keys = Array.from(Array(1e4).keys()); +var set = new Set(keys); + +// ---------------------------------------------------------------------------- +// Benchmark: Spread +// ---------------------------------------------------------------------------- + +function Spread() { + var newArr = [...set]; + // basic sanity check + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: SpreadKeys +// ---------------------------------------------------------------------------- + +function SpreadKeys() { + var newArr = [...set.keys()]; + // basic sanity check + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: SpreadValues +// ---------------------------------------------------------------------------- + +function SpreadValues() { + var newArr = [...set.values()]; + // basic sanity check + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOf +// ---------------------------------------------------------------------------- + +function ForOf() { + var newArr = new Array(set.size); + var i = 0; + for (let x of set) { + newArr[i] = x; + i++; + } + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfKeys +// ---------------------------------------------------------------------------- + +function ForOfKeys() { + var newArr = new Array(set.size); + var i = 0; + for (let x of set.keys()) { + newArr[i] = x; + i++; + } + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfValues +// ---------------------------------------------------------------------------- + +function ForOfValues() { + var newArr = new Array(set.size); + var i = 0; + for (let kv of set.values()) { + newArr[i] = kv; + i++; + } + if (newArr.length != set.size) throw 666; + return newArr; +} + + +// ---------------------------------------------------------------------------- +// Setup and Run +// ---------------------------------------------------------------------------- + +load('../base.js'); + +var success = true; + +function PrintResult(name, result) { + print(name + '-ArrayLiteralInitialSpreadLargeSmiSet(Score): ' + result); +} + +function PrintError(name, error) { + PrintResult('Error: ' + name, error); + success = false; +} + +function CreateBenchmark(name, f) { + new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 0, f) ]); +} + +CreateBenchmark('ForOf', ForOf); +CreateBenchmark('ForOfKeys', ForOfKeys); +CreateBenchmark('ForOfValues', ForOfValues); +CreateBenchmark('Spread', Spread); +CreateBenchmark('SpreadKeys', SpreadKeys); +CreateBenchmark('SpreadValues', SpreadValues); + + +BenchmarkSuite.config.doWarmup = true; +BenchmarkSuite.config.doDeterministic = false; +BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError}); diff --git a/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallDoubleHoley/run.js b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallDoubleHoley/run.js new file mode 100644 index 0000000000..19768b73aa --- /dev/null +++ b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallDoubleHoley/run.js @@ -0,0 +1,159 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Comparing different copy schemes against spread initial literals. +// Benchmarks for small holey double arrays. + +const smallHoleyArray = Array(100); + +for (var i = 0; i < 10; i++) { + smallHoleyArray[i] = i + 6.66; +} +for (var i = 90; i < 99; i++) { + smallHoleyArray[i] = i + 6.66; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Spread +// ---------------------------------------------------------------------------- + +function SpreadSmallHoley() { + var newArr = [...smallHoleyArray]; + // basic sanity check + if (newArr.length != smallHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForLength +// ---------------------------------------------------------------------------- + +function ForLengthSmallHoley() { + var newArr = new Array(smallHoleyArray.length); + for (let i = 0; i < smallHoleyArray.length; i++) { + newArr[i] = smallHoleyArray[i]; + } + // basic sanity check + if (newArr.length != smallHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForLengthEmpty +// ---------------------------------------------------------------------------- + +function ForLengthEmptySmallHoley() { + var newArr = []; + for (let i = 0; i < smallHoleyArray.length; i++) { + newArr[i] = smallHoleyArray[i]; + } + // basic sanity check + if (newArr.length != smallHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Slice +// ---------------------------------------------------------------------------- + +function SliceSmallHoley() { + var newArr = smallHoleyArray.slice(); + // basic sanity check + if (newArr.length != smallHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Slice0 +// ---------------------------------------------------------------------------- + +function Slice0SmallHoley() { + var newArr = smallHoleyArray.slice(0); + // basic sanity check + if (newArr.length != smallHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ConcatReceive +// ---------------------------------------------------------------------------- + +function ConcatReceiveSmallHoley() { + var newArr = smallHoleyArray.concat(); + // basic sanity check + if (newArr.length != smallHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ConcatArg +// ---------------------------------------------------------------------------- + +function ConcatArgSmallHoley() { + var newArr = [].concat(smallHoleyArray); + // basic sanity check + if (newArr.length != smallHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfPush +// ---------------------------------------------------------------------------- + +function ForOfPushSmallHoley() { + var newArr = []; + for (let x of smallHoleyArray) { + newArr.push(x) + } + // basic sanity check + if (newArr.length != smallHoleyArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: MapId +// ---------------------------------------------------------------------------- + +function MapIdSmallHoley() { + var newArr = smallHoleyArray.map(x => x); + // basic sanity check + if (newArr.length != smallHoleyArray.length) throw 666; + return newArr; +} + + +// ---------------------------------------------------------------------------- +// Setup and Run +// ---------------------------------------------------------------------------- + +load('../base.js'); + +var success = true; + +function PrintResult(name, result) { + print(name + '-ArrayLiteralInitialSpreadSmallDoubleHoley(Score): ' + result); +} + +function PrintError(name, error) { + PrintResult('Error: ' + name, error); + success = false; +} + +function CreateBenchmark(name, f) { + new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 0, f) ]); +} + +CreateBenchmark('Spread', SpreadSmallHoley); +CreateBenchmark('ForLength', ForLengthSmallHoley); +CreateBenchmark('ForLengthEmpty', ForLengthEmptySmallHoley); +CreateBenchmark('Slice', SliceSmallHoley); +CreateBenchmark('Slice0', Slice0SmallHoley); +CreateBenchmark('ConcatReceive', ConcatReceiveSmallHoley); +CreateBenchmark('ConcatArg', ConcatArgSmallHoley); +CreateBenchmark('ForOfPush', ForOfPushSmallHoley); +CreateBenchmark('MapId', MapIdSmallHoley); + +BenchmarkSuite.config.doWarmup = true; +BenchmarkSuite.config.doDeterministic = false; +BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError}); diff --git a/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallDoublePacked/run.js b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallDoublePacked/run.js new file mode 100644 index 0000000000..88d382c4fc --- /dev/null +++ b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallDoublePacked/run.js @@ -0,0 +1,158 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Comparing different copy schemes against spread initial literals. +// Benchmarks for small packed double arrays. + +var smallArray = Array.from(Array(100).keys()); + +for (var i = 0; i < 100; i++) { + smallArray[i] += 6.66; +} + + +// ---------------------------------------------------------------------------- +// Benchmark: Spread +// ---------------------------------------------------------------------------- + +function SpreadSmall() { + var newArr = [...smallArray]; + // basic sanity check + if (newArr.length != smallArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForLength +// ---------------------------------------------------------------------------- + +function ForLengthSmall() { + var newArr = new Array(smallArray.length); + for (let i = 0; i < smallArray.length; i++) { + newArr[i] = smallArray[i]; + } + // basic sanity check + if (newArr.length != smallArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForLengthEmpty +// ---------------------------------------------------------------------------- + +function ForLengthEmptySmall() { + var newArr = []; + for (let i = 0; i < smallArray.length; i++) { + newArr[i] = smallArray[i]; + } + // basic sanity check + if (newArr.length != smallArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Slice +// ---------------------------------------------------------------------------- + +function SliceSmall() { + var newArr = smallArray.slice(); + // basic sanity check + if (newArr.length != smallArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: Slice0 +// ---------------------------------------------------------------------------- + +function Slice0Small() { + var newArr = smallArray.slice(0); + // basic sanity check + if (newArr.length != smallArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ConcatReceive +// ---------------------------------------------------------------------------- + +function ConcatReceiveSmall() { + var newArr = smallArray.concat(); + // basic sanity check + if (newArr.length != smallArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ConcatArg +// ---------------------------------------------------------------------------- + +function ConcatArgSmall() { + var newArr = [].concat(smallArray); + // basic sanity check + if (newArr.length != smallArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfPush +// ---------------------------------------------------------------------------- + +function ForOfPushSmall() { + var newArr = []; + for (let x of smallArray) { + newArr.push(x) + } + // basic sanity check + if (newArr.length != smallArray.length) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: MapId +// ---------------------------------------------------------------------------- + +function MapIdSmall() { + var newArr = smallArray.map(x => x); + // basic sanity check + if (newArr.length != smallArray.length) throw 666; + return newArr; +} + + +// ---------------------------------------------------------------------------- +// Setup and Run +// ---------------------------------------------------------------------------- + +load('../base.js'); + +var success = true; + +function PrintResult(name, result) { + print(name + '-ArrayLiteralInitialSpreadSmallDoublePacked(Score): ' + result); +} + +function PrintError(name, error) { + PrintResult('Error: ' + name, error); + success = false; +} + +function CreateBenchmark(name, f) { + new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 0, f) ]); +} + +CreateBenchmark('Spread', SpreadSmall); +CreateBenchmark('ForLength', ForLengthSmall); +CreateBenchmark('ForLengthEmpty', ForLengthEmptySmall); +CreateBenchmark('Slice', SliceSmall); +CreateBenchmark('Slice0', Slice0Small); +CreateBenchmark('ConcatReceive', ConcatReceiveSmall); +CreateBenchmark('ConcatArg', ConcatArgSmall); +CreateBenchmark('ForOfPush', ForOfPushSmall); +CreateBenchmark('MapId', MapIdSmall); + + +BenchmarkSuite.config.doWarmup = true; +BenchmarkSuite.config.doDeterministic = false; +BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError}); diff --git a/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallSmiMap/run.js b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallSmiMap/run.js new file mode 100644 index 0000000000..a2f8bad5c0 --- /dev/null +++ b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallSmiMap/run.js @@ -0,0 +1,93 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Comparing different iterating schemes against spread initial literals. +// Benchmarks for small smi maps. + +var keys = Array.from(Array(50).keys()); +var keyValuePairs = keys.map((value) => [value, value + 1]); +var map = new Map(keyValuePairs); + +// ---------------------------------------------------------------------------- +// Benchmark: SpreadKeys +// ---------------------------------------------------------------------------- + +function SpreadKeys() { + var newArr = [...map.keys()]; + // basic sanity check + if (newArr.length != map.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: SpreadValues +// ---------------------------------------------------------------------------- + +function SpreadValues() { + var newArr = [...map.values()]; + // basic sanity check + if (newArr.length != map.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfKeys +// ---------------------------------------------------------------------------- + +function ForOfKeys() { + var newArr = new Array(map.size); + var i = 0; + for (let x of map.keys()) { + newArr[i] = x; + i++; + } + if (newArr.length != map.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfValues +// ---------------------------------------------------------------------------- + +function ForOfValues() { + var newArr = new Array(map.size); + var i = 0; + for (let x of map.values()) { + newArr[i] = x; + i++; + } + if (newArr.length != map.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Setup and Run +// ---------------------------------------------------------------------------- + +load('../base.js'); + +var success = true; + +function PrintResult(name, result) { + print(name + '-ArrayLiteralInitialSpreadSmallSmiMap(Score): ' + result); +} + +function PrintError(name, error) { + PrintResult('Error: ' + name, error); + success = false; +} + +function CreateBenchmark(name, f) { + new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 0, f) ]); +} + +CreateBenchmark('ForOfKeys', ForOfKeys); +CreateBenchmark('ForOfValues', ForOfValues); +CreateBenchmark('SpreadKeys', SpreadKeys); +CreateBenchmark('SpreadValues', SpreadValues); + + +BenchmarkSuite.config.doWarmup = true; +BenchmarkSuite.config.doDeterministic = false; +BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError}); diff --git a/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallSmiSet/run.js b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallSmiSet/run.js new file mode 100644 index 0000000000..35e9bcec07 --- /dev/null +++ b/deps/v8/test/js-perf-test/ArrayLiteralInitialSpreadSmallSmiSet/run.js @@ -0,0 +1,120 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Comparing different iterating schemes against spread initial literals. +// Benchmarks for small smi sets. + +var keys = Array.from(Array(50).keys()); +var set = new Set(keys); + +// ---------------------------------------------------------------------------- +// Benchmark: Spread +// ---------------------------------------------------------------------------- + +function Spread() { + var newArr = [...set]; + // basic sanity check + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: SpreadKeys +// ---------------------------------------------------------------------------- + +function SpreadKeys() { + var newArr = [...set.keys()]; + // basic sanity check + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: SpreadValues +// ---------------------------------------------------------------------------- + +function SpreadValues() { + var newArr = [...set.values()]; + // basic sanity check + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOf +// ---------------------------------------------------------------------------- + +function ForOf() { + var newArr = new Array(set.size); + var i = 0; + for (let x of set) { + newArr[i] = x; + i++; + } + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfKeys +// ---------------------------------------------------------------------------- + +function ForOfKeys() { + var newArr = new Array(set.size); + var i = 0; + for (let x of set.keys()) { + newArr[i] = x; + i++; + } + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Benchmark: ForOfValues +// ---------------------------------------------------------------------------- + +function ForOfValues() { + var newArr = new Array(set.size); + var i = 0; + for (let x of set.values()) { + newArr[i] = x; + i++; + } + if (newArr.length != set.size) throw 666; + return newArr; +} + +// ---------------------------------------------------------------------------- +// Setup and Run +// ---------------------------------------------------------------------------- + +load('../base.js'); + +var success = true; + +function PrintResult(name, result) { + print(name + '-ArrayLiteralInitialSpreadSmallSmiSet(Score): ' + result); +} + +function PrintError(name, error) { + PrintResult('Error: ' + name, error); + success = false; +} + +function CreateBenchmark(name, f) { + new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 0, f) ]); +} + +CreateBenchmark('ForOf', ForOf); +CreateBenchmark('ForOfKeys', ForOfKeys); +CreateBenchmark('ForOfValues', ForOfValues); +CreateBenchmark('Spread', Spread); +CreateBenchmark('SpreadKeys', SpreadKeys); +CreateBenchmark('SpreadValues', SpreadValues); + + +BenchmarkSuite.config.doWarmup = true; +BenchmarkSuite.config.doDeterministic = false; +BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError}); diff --git a/deps/v8/test/js-perf-test/AsyncAwait/baseline-babel-es2017.js b/deps/v8/test/js-perf-test/AsyncAwait/baseline-babel-es2017.js index 1be3074f3b..37709d739b 100644 --- a/deps/v8/test/js-perf-test/AsyncAwait/baseline-babel-es2017.js +++ b/deps/v8/test/js-perf-test/AsyncAwait/baseline-babel-es2017.js @@ -160,10 +160,10 @@ function Setup() { return a; })(); - %RunMicrotasks(); + %PerformMicrotaskCheckpoint(); } function Basic() { a(); - %RunMicrotasks(); + %PerformMicrotaskCheckpoint(); } diff --git a/deps/v8/test/js-perf-test/AsyncAwait/baseline-naive-promises.js b/deps/v8/test/js-perf-test/AsyncAwait/baseline-naive-promises.js index f59ae86194..9b9c091a13 100644 --- a/deps/v8/test/js-perf-test/AsyncAwait/baseline-naive-promises.js +++ b/deps/v8/test/js-perf-test/AsyncAwait/baseline-naive-promises.js @@ -34,7 +34,7 @@ function Setup() { b = function b(p) { return p; }; a = function a(p) { return p; }; - %RunMicrotasks(); + %PerformMicrotaskCheckpoint(); } function Basic() { @@ -48,5 +48,5 @@ function Basic() { .then(c) .then(b) .then(a); - %RunMicrotasks(); + %PerformMicrotaskCheckpoint(); } diff --git a/deps/v8/test/js-perf-test/AsyncAwait/native.js b/deps/v8/test/js-perf-test/AsyncAwait/native.js index 7979d2f4db..e9504c3a19 100644 --- a/deps/v8/test/js-perf-test/AsyncAwait/native.js +++ b/deps/v8/test/js-perf-test/AsyncAwait/native.js @@ -34,10 +34,10 @@ function Setup() { b = async function b() { return c(); }; a = async function a() { return b(); }; - %RunMicrotasks(); + %PerformMicrotaskCheckpoint(); } function Basic() { a(); - %RunMicrotasks(); + %PerformMicrotaskCheckpoint(); } diff --git a/deps/v8/test/js-perf-test/Dates/run.js b/deps/v8/test/js-perf-test/Dates/run.js new file mode 100644 index 0000000000..c57e56990a --- /dev/null +++ b/deps/v8/test/js-perf-test/Dates/run.js @@ -0,0 +1,20 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +load('../base.js'); +load('toLocaleString.js'); + +function PrintResult(name, result) { + console.log(name); + console.log(name + '-Dates(Score): ' + result); +} + +function PrintError(name, error) { + PrintResult(name, error); +} + +BenchmarkSuite.config.doWarmup = undefined; +BenchmarkSuite.config.doDeterministic = undefined; + +BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, + NotifyError: PrintError }); diff --git a/deps/v8/test/js-perf-test/Dates/toLocaleString.js b/deps/v8/test/js-perf-test/Dates/toLocaleString.js new file mode 100644 index 0000000000..fd89a7cdb8 --- /dev/null +++ b/deps/v8/test/js-perf-test/Dates/toLocaleString.js @@ -0,0 +1,20 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +function DateToLocaleDateString() { + let d = new Date(); + d.toLocaleDateString() +} +createSuite('toLocaleDateString', 100000, DateToLocaleDateString, ()=>{}); + +function DateToLocaleString() { + let d = new Date(); + d.toLocaleString() +} +createSuite('toLocaleString', 100000, DateToLocaleString, ()=>{}); + +function DateToLocaleTimeString() { + let d = new Date(); + d.toLocaleTimeString() +} +createSuite('toLocaleTimeString', 100000, DateToLocaleTimeString, ()=>{}); diff --git a/deps/v8/test/js-perf-test/Inspector/debugger.js b/deps/v8/test/js-perf-test/Inspector/debugger.js index 8e44aa7710..e9c862563b 100644 --- a/deps/v8/test/js-perf-test/Inspector/debugger.js +++ b/deps/v8/test/js-perf-test/Inspector/debugger.js @@ -69,7 +69,7 @@ function AsyncStacksInstrumentation() { p = p.then(nopCallback); } p = p.then(() => done = true); - while (!done) %RunMicrotasks(); + while (!done) %PerformMicrotaskCheckpoint(); } })(); diff --git a/deps/v8/test/js-perf-test/JSTests.json b/deps/v8/test/js-perf-test/JSTests.json index c2aacb452f..88f39b9fa8 100644 --- a/deps/v8/test/js-perf-test/JSTests.json +++ b/deps/v8/test/js-perf-test/JSTests.json @@ -128,6 +128,130 @@ ] }, { + "name": "ArrayLiteralInitialSpreadSmallDoublePacked", + "path": ["ArrayLiteralInitialSpreadSmallDoublePacked"], + "main": "run.js", + "resources": [], + "results_regexp": "^%s\\-ArrayLiteralInitialSpreadSmallDoublePacked\\(Score\\): (.+)$", + "tests": [ + {"name": "Spread"}, + {"name": "ForLength"}, + {"name": "ForLengthEmpty"}, + {"name": "Slice"}, + {"name": "Slice0"}, + {"name": "ConcatReceive"}, + {"name": "ConcatArg"}, + {"name": "ForOfPush"}, + {"name": "MapId"} + ] + }, + { + "name": "ArrayLiteralInitialSpreadLargeDoublePacked", + "path": ["ArrayLiteralInitialSpreadLargeDoublePacked"], + "main": "run.js", + "resources": [], + "results_regexp": "^%s\\-ArrayLiteralInitialSpreadLargeDoublePacked\\(Score\\): (.+)$", + "tests": [ + {"name": "Spread"}, + {"name": "ForLength"}, + {"name": "ForLengthEmpty"}, + {"name": "Slice"}, + {"name": "Slice0"}, + {"name": "ConcatReceive"}, + {"name": "ConcatArg"} + ] + }, + { + "name": "ArrayLiteralInitialSpreadSmallDoubleHoley", + "path": ["ArrayLiteralInitialSpreadSmallDoubleHoley"], + "main": "run.js", + "resources": [], + "results_regexp": "^%s\\-ArrayLiteralInitialSpreadSmallDoubleHoley\\(Score\\): (.+)$", + "tests": [ + {"name": "Spread"}, + {"name": "ForLength"}, + {"name": "ForLengthEmpty"}, + {"name": "Slice"}, + {"name": "Slice0"}, + {"name": "ConcatReceive"}, + {"name": "ConcatArg"}, + {"name": "ForOfPush"}, + {"name": "MapId"} + ] + }, + { + "name": "ArrayLiteralInitialSpreadLargeDoubleHoley", + "path": ["ArrayLiteralInitialSpreadLargeDoubleHoley"], + "main": "run.js", + "resources": [], + "results_regexp": "^%s\\-ArrayLiteralInitialSpreadLargeDoubleHoley\\(Score\\): (.+)$", + "tests": [ + {"name": "Spread"}, + {"name": "ForLength"}, + {"name": "ForLengthEmpty"}, + {"name": "Slice"}, + {"name": "Slice0"}, + {"name": "ConcatReceive"}, + {"name": "ConcatArg"} + ] + }, + { + "name": "ArrayLiteralInitialSpreadSmallSmiMap", + "path": ["ArrayLiteralInitialSpreadSmallSmiMap"], + "main": "run.js", + "resources": [], + "results_regexp": "^%s\\-ArrayLiteralInitialSpreadSmallSmiMap\\(Score\\): (.+)$", + "tests": [ + {"name": "ForOfKeys"}, + {"name": "ForOfValues"}, + {"name": "SpreadKeys"}, + {"name": "SpreadValues"} + ] + }, + { + "name": "ArrayLiteralInitialSpreadLargeSmiMap", + "path": ["ArrayLiteralInitialSpreadLargeSmiMap"], + "main": "run.js", + "resources": [], + "results_regexp": "^%s\\-ArrayLiteralInitialSpreadLargeSmiMap\\(Score\\): (.+)$", + "tests": [ + {"name": "ForOfKeys"}, + {"name": "ForOfValues"}, + {"name": "SpreadKeys"}, + {"name": "SpreadValues"} + ] + }, + { + "name": "ArrayLiteralInitialSpreadSmallSmiSet", + "path": ["ArrayLiteralInitialSpreadSmallSmiSet"], + "main": "run.js", + "resources": [], + "results_regexp": "^%s\\-ArrayLiteralInitialSpreadSmallSmiSet\\(Score\\): (.+)$", + "tests": [ + {"name": "ForOf"}, + {"name": "ForOfKeys"}, + {"name": "ForOfValues"}, + {"name": "Spread"}, + {"name": "SpreadKeys"}, + {"name": "SpreadValues"} + ] + }, + { + "name": "ArrayLiteralInitialSpreadLargeSmiSet", + "path": ["ArrayLiteralInitialSpreadLargeSmiSet"], + "main": "run.js", + "resources": [], + "results_regexp": "^%s\\-ArrayLiteralInitialSpreadLargeSmiSet\\(Score\\): (.+)$", + "tests": [ + {"name": "ForOf"}, + {"name": "ForOfKeys"}, + {"name": "ForOfValues"}, + {"name": "Spread"}, + {"name": "SpreadKeys"}, + {"name": "SpreadValues"} + ] + }, + { "name": "ArrayLiteralSpread", "path": ["ArrayLiteralSpread"], "main": "run.js", @@ -359,6 +483,17 @@ ] }, { + "name": "StringLocaleCompare", + "main": "run.js", + "resources": [ "string-localeCompare.js" ], + "test_flags": [ "string-localeCompare" ], + "results_regexp": "^%s\\-Strings\\(Score\\): (.+)$", + "run_count": 1, + "tests": [ + {"name": "StringLocaleCompare"} + ] + }, + { "name": "StringMatchAll", "main": "run.js", "resources": [ "string-matchall.js" ], @@ -394,6 +529,21 @@ ] }, { + "name": "StringStartsWith", + "main": "run.js", + "resources": [ "string-startswith.js" ], + "test_flags": [ "string-startswith" ], + "results_regexp": "^%s\\-Strings\\(Score\\): (.+)$", + "run_count": 1, + "flags": [ "--allow-natives-syntax" ], + "tests": [ + {"name": "DirectStringsDirectSearch"}, + {"name": "ConsStringsDirectSearch"}, + {"name": "DirectStringsConsSearch"}, + {"name": "ConsStringsConsSearch"} + ] + }, + { "name": "StringSubstring", "main": "run.js", "resources": [ "string-substring.js" ], @@ -610,6 +760,42 @@ "test_flags": ["construct-all-typedarrays"] }, { + "name": "JoinBigIntTypes", + "main": "run.js", + "resources": ["base.js", "join.js", "join-bigint.js"], + "test_flags": ["join-bigint"] + }, + { + "name": "JoinFloatTypes", + "main": "run.js", + "resources": ["base.js", "join.js", "join-float.js"], + "test_flags": ["join-float"] + }, + { + "name": "JoinIntTypes", + "main": "run.js", + "resources": ["base.js", "join.js", "join-int.js"], + "test_flags": ["join-int"] + }, + { + "name": "JoinWithSeparatorBigIntTypes", + "main": "run.js", + "resources": ["base.js", "join.js", "join-sep-bigint.js"], + "test_flags": ["join-sep-bigint"] + }, + { + "name": "JoinWithSeparatorFloatTypes", + "main": "run.js", + "resources": ["base.js", "join.js", "join-sep-float.js"], + "test_flags": ["join-sep-float"] + }, + { + "name": "JoinWithSeparatorIntTypes", + "main": "run.js", + "resources": ["base.js", "join.js", "join-sep-int.js"], + "test_flags": ["join-sep-int"] + }, + { "name": "SetFromArrayLike", "main": "run.js", "resources": ["set-from-arraylike.js"], @@ -636,37 +822,37 @@ { "name": "SortIntTypes", "main": "run.js", - "resources": ["sort.js", "sort-int.js"], + "resources": ["base.js", "sort.js", "sort-int.js"], "test_flags": ["sort-int"] }, { "name": "SortBigIntTypes", "main": "run.js", - "resources": ["sort.js", "sort-bigint.js"], + "resources": ["base.js", "sort.js", "sort-bigint.js"], "test_flags": ["sort-bigint"] }, { "name": "SortFloatTypes", "main": "run.js", - "resources": ["sort.js", "sort-float.js"], + "resources": ["base.js", "sort.js", "sort-float.js"], "test_flags": ["sort-float"] }, { "name": "SortCustomCompareFnIntTypes", "main": "run.js", - "resources": ["sort.js", "sort-cmpfn-int.js"], + "resources": ["base.js", "sort.js", "sort-cmpfn-int.js"], "test_flags": ["sort-cmpfn-int"] }, { "name": "SortCustomCompareFnBigIntTypes", "main": "run.js", - "resources": ["sort.js", "sort-cmpfn-bigint.js"], + "resources": ["base.js", "sort.js", "sort-cmpfn-bigint.js"], "test_flags": ["sort-cmpfn-bigint"] }, { "name": "SortCustomCompareFnFloatTypes", "main": "run.js", - "resources": ["sort.js", "sort-cmpfn-float.js"], + "resources": ["base.js", "sort.js", "sort-cmpfn-float.js"], "test_flags": ["sort-cmpfn-float"] }, { @@ -763,13 +949,18 @@ {"name": "SmallMixedArrayOf"}, {"name": "SmiFrom"}, {"name": "SmallSmiFrom"}, - {"name": "SmiNoMapFrom"}, + {"name": "SmiCowNoMapFrom"}, + {"name": "SmiNonCowNoMapFrom"}, {"name": "SmiNoIteratorFrom"}, {"name": "TransplantedFrom"}, {"name": "DoubleFrom"}, + {"name": "DoubleNoMapFrom"}, {"name": "StringFrom"}, - {"name": "StringNoMapFrom"}, + {"name": "StringCowNoMapFrom"}, + {"name": "StringNonCowNoMapFrom"}, {"name": "MixedFrom"}, + {"name": "MixedCowNoMapFrom"}, + {"name": "MixedNonCowNoMapFrom"}, {"name": "Array.slice(500)"}, {"name": "Array.slice(500,999)"}, {"name": "Array.slice(-500)"}, @@ -787,6 +978,22 @@ ] }, { + "name": "ArrayIndexOfIncludesPolymorphic", + "path": ["ArrayIndexOfIncludesPolymorphic"], + "main": "run.js", + "resources": ["indexof-includes-polymorphic.js"], + "test_flags": ["indexof-includes-polymorphic"], + "results_regexp": "^%s\\-ArrayIndexOfIncludesPolymorphic\\(Score\\): (.+)$", + "flags": [ + "--allow-natives-syntax" + ], + "tests": [ + {"name": "for loop"}, + {"name": "Array#indexOf"}, + {"name": "Array#includes"} + ] + }, + { "name": "ArraySort", "path": ["ArraySort"], "main": "run.js", @@ -1061,6 +1268,18 @@ ] }, { + "name": "Dates", + "path": ["Dates"], + "main": "run.js", + "resources": ["toLocaleString.js"], + "results_regexp": "^%s\\-Dates\\(Score\\): (.+)$", + "tests": [ + {"name": "toLocaleDateString"}, + {"name": "toLocaleString"}, + {"name": "toLocaleTimeString"} + ] + }, + { "name": "ExpressionDepth", "path": ["ExpressionDepth"], "main": "run.js", @@ -1126,12 +1345,16 @@ "path": ["Numbers"], "main": "run.js", "flags": ["--allow-natives-syntax"], - "resources": [ "toNumber.js"], + "resources": [ + "toNumber.js", + "toLocaleString.js" + ], "results_regexp": "^%s\\-Numbers\\(Score\\): (.+)$", "tests": [ {"name": "Constructor"}, {"name": "UnaryPlus"}, - {"name": "ParseFloat"} + {"name": "ParseFloat"}, + {"name": "toLocaleString"} ] }, { diff --git a/deps/v8/test/js-perf-test/Modules/run.js b/deps/v8/test/js-perf-test/Modules/run.js index e5f91e1aa9..4c038801a9 100644 --- a/deps/v8/test/js-perf-test/Modules/run.js +++ b/deps/v8/test/js-perf-test/Modules/run.js @@ -23,21 +23,21 @@ const iterations = 10000; function BasicExport() { let success = false; import("basic-export.js").then(m => { m.bench(); success = true; }); - %RunMicrotasks(); + %PerformMicrotaskCheckpoint(); if (!success) throw new Error(666); } function BasicImport() { let success = false; import("basic-import.js").then(m => { m.bench(); success = true; }); - %RunMicrotasks(); + %PerformMicrotaskCheckpoint(); if (!success) throw new Error(666); } function BasicNamespace() { let success = false; import("basic-namespace.js").then(m => { m.bench(); success = true; }); - %RunMicrotasks(); + %PerformMicrotaskCheckpoint(); if (!success) throw new Error(666); } diff --git a/deps/v8/test/js-perf-test/Numbers/run.js b/deps/v8/test/js-perf-test/Numbers/run.js index cdfbf25a70..d48227826a 100644 --- a/deps/v8/test/js-perf-test/Numbers/run.js +++ b/deps/v8/test/js-perf-test/Numbers/run.js @@ -3,6 +3,7 @@ // found in the LICENSE file. load('../base.js'); load('toNumber.js'); +load('toLocaleString.js'); function PrintResult(name, result) { console.log(name); diff --git a/deps/v8/test/js-perf-test/Numbers/toLocaleString.js b/deps/v8/test/js-perf-test/Numbers/toLocaleString.js new file mode 100644 index 0000000000..8dd5a535ad --- /dev/null +++ b/deps/v8/test/js-perf-test/Numbers/toLocaleString.js @@ -0,0 +1,14 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function NumberToLocaleString() { + Number(0).toLocaleString() + Number(-12).toLocaleString() + Number(13).toLocaleString() + Number(123456789).toLocaleString() + Number(1234567.89).toLocaleString() + Number(-123456789).toLocaleString() + Number(-1234567.89).toLocaleString() +} +createSuite('toLocaleString', 100000, NumberToLocaleString, ()=>{}); diff --git a/deps/v8/test/js-perf-test/RegExp/base.js b/deps/v8/test/js-perf-test/RegExp/base.js index 31f7206f07..3883b7f939 100644 --- a/deps/v8/test/js-perf-test/RegExp/base.js +++ b/deps/v8/test/js-perf-test/RegExp/base.js @@ -5,6 +5,7 @@ function benchName(bench, setup) { var name = bench.name; if (setup) name += "/" + setup.name; + return name; } function slowBenchName(bench, setup) { @@ -30,7 +31,7 @@ function createBenchmarkSuite(name) { return new BenchmarkSuite( name, [1000], benchmarks.map(([bench, setup]) => - new Benchmark(benchName(bench, setup), false, false, 0, bench, + new Benchmark(benchName(bench, setup), false, false, 100000, bench, setup))); } diff --git a/deps/v8/test/js-perf-test/StringIterators/string-iterator.js b/deps/v8/test/js-perf-test/StringIterators/string-iterator.js index 8a7e323b42..e46526447c 100644 --- a/deps/v8/test/js-perf-test/StringIterators/string-iterator.js +++ b/deps/v8/test/js-perf-test/StringIterators/string-iterator.js @@ -21,8 +21,8 @@ function Spread_OneByteShort() { function Spread_OneByteShortTearDown() { var expected = "A|l|p|h|a|b|e|t|-|S|o|u|p"; - return assert(Array.isArray(result)) - && assertEquals(expected, result.join("|")); + assert(Array.isArray(result)); + assertEquals(expected, result.join("|")); } // ---------------------------------------------------------------------------- @@ -44,8 +44,8 @@ function Spread_TwoByteShort() { function Spread_TwoByteShortTearDown() { var expected = "\u5FCD|\u8005|\u306E|\u653B|\u6483"; - return assert(Array.isArray(result)) - && assertEquals(expected, result.join("|")); + assert(Array.isArray(result)); + assertEquals(expected, result.join("|")); } // ---------------------------------------------------------------------------- @@ -69,8 +69,8 @@ function Spread_WithSurrogatePairsShort() { function Spread_WithSurrogatePairsShortTearDown() { var expected = "\uD83C\uDF1F|\u5FCD|\u8005|\u306E|\u653B|\u6483|\uD83C\uDF1F"; - return assert(Array.isArray(result)) - && assertEquals(expected, result.join("|")); + assert(Array.isArray(result)); + assertEquals(expected, result.join("|")); } // ---------------------------------------------------------------------------- @@ -92,7 +92,7 @@ function ForOf_OneByteShort() { } function ForOf_OneByteShortTearDown() { - return assertEquals(string, result); + assertEquals(string, result); } // ---------------------------------------------------------------------------- @@ -114,7 +114,7 @@ function ForOf_TwoByteShort() { } function ForOf_TwoByteShortTearDown() { - return assertEquals(string, result); + assertEquals(string, result); } // ---------------------------------------------------------------------------- @@ -137,7 +137,7 @@ function ForOf_WithSurrogatePairsShort() { } function ForOf_WithSurrogatePairsShortTearDown() { - return assertEquals(string, result); + assertEquals(string, result); } // ---------------------------------------------------------------------------- @@ -159,7 +159,7 @@ function ForOf_OneByteLong() { } function ForOf_OneByteLongTearDown() { - return assertEquals(string, result); + assertEquals(string, result); } // ---------------------------------------------------------------------------- @@ -181,7 +181,7 @@ function ForOf_TwoByteLong() { } function ForOf_TwoByteLongTearDown() { - return assertEquals(string, result); + assertEquals(string, result); } // ---------------------------------------------------------------------------- @@ -204,5 +204,5 @@ function ForOf_WithSurrogatePairsLong() { } function ForOf_WithSurrogatePairsLongTearDown() { - return assertEquals(string, result); + assertEquals(string, result); } diff --git a/deps/v8/test/js-perf-test/Strings/string-localeCompare.js b/deps/v8/test/js-perf-test/Strings/string-localeCompare.js new file mode 100644 index 0000000000..6c8b609825 --- /dev/null +++ b/deps/v8/test/js-perf-test/Strings/string-localeCompare.js @@ -0,0 +1,19 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +new BenchmarkSuite('StringLocaleCompare', [1000000], [ + new Benchmark('StringLocaleCompare', false, false, 0, + StringLocaleCompare), +]); + +function StringLocaleCompare() { + var array = ["XYZ", "mno", "abc", "EFG", "ijk", "123", "tuv", "234", "efg"]; + + var sum = 0; + for (var j = 0; j < array.length; ++j) { + sum += "fox".localeCompare(array[j]); + } + + return sum; +} diff --git a/deps/v8/test/js-perf-test/Strings/string-startswith.js b/deps/v8/test/js-perf-test/Strings/string-startswith.js new file mode 100644 index 0000000000..4b0379b3a3 --- /dev/null +++ b/deps/v8/test/js-perf-test/Strings/string-startswith.js @@ -0,0 +1,78 @@ +// Copyright 2019 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function createSuite(name, count, fn) { + new BenchmarkSuite(name, [count], [new Benchmark(name, true, false, 0, fn)]); +} + +const inputs = [ + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + 'Integer eu augue suscipit, accumsan ipsum nec, sagittis sem.', + 'In vitae pellentesque dolor. Curabitur leo nunc, luctus vitae', + 'risus eget, fermentum hendrerit justo.', + 'hello'.repeat(1024), + 'h', + '' +]; +const firsts = ['I', 'Integer', 'Lorem', 'risus', 'hello']; + +function simpleHelper() { + let sum = 0; + for (const input of inputs) { + for (const first of firsts) { + sum += input.startsWith(first); + } + } + return sum; +} + +function consInputHelper() { + let sum = 0; + for (const inputOne of inputs) { + for (const inputTwo of inputs) { + for (const first of firsts) { + // Skip if the length is too small for %ConstructConsString + if (inputOne.length + inputTwo.length < 13) break; + sum += %ConstructConsString(inputOne, inputTwo).startsWith(first); + } + } + } + return sum; +} + +function consFirstHelper() { + let sum = 0; + for (const input of inputs) { + for (const firstOne of firsts) { + for (const firstTwo of firsts) { + // Skip if the length is too small for %ConstructConsString + if (firstOne.length + firstTwo.length < 13) break; + sum += input.startsWith(%ConstructConsString(firstOne, firstTwo)); + } + } + } + return sum; +} + +function doubleConsHelper() { + let sum = 0; + for (const inputOne of inputs) { + for (const inputTwo of inputs) { + for (const firstOne of firsts) { + for (const firstTwo of firsts) { + // Skip if the length is too small for %ConstructConsString + if (inputOne.length + inputTwo.length < 13 || firstOne.length + firstTwo.length) break; + sum += % ConstructConsString(inputOne, inputTwo).startsWith( + % ConstructConsString(firstOne, firstTwo) + ); + } + } + } + } +} + +createSuite('DirectStringsDirectSearch', 1000, simpleHelper); +createSuite('ConsStringsDirectSearch', 1000, consInputHelper); +createSuite('DirectStringsConsSearch', 1000, consFirstHelper); +createSuite('ConsStringsConsSearch', 1000, doubleConsHelper); diff --git a/deps/v8/test/js-perf-test/TypedArrays/base.js b/deps/v8/test/js-perf-test/TypedArrays/base.js new file mode 100644 index 0000000000..04f65a6ea6 --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/base.js @@ -0,0 +1,26 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const typedArrayIntConstructors = [ + {name: "Uint8", ctor: Uint8Array}, + {name: "Int8", ctor: Int8Array}, + {name: "Uint16", ctor: Uint16Array}, + {name: "Int16", ctor: Int16Array}, + {name: "Uint32", ctor: Uint32Array}, + {name: "Int32", ctor: Int32Array}, + {name: "Uint8Clamped", ctor: Uint8ClampedArray}, +]; + +const typedArrayFloatConstructors = [ + {name: "Float32", ctor: Float32Array}, + {name: "Float64", ctor: Float64Array}, +]; + +// "ref" builds might not yet have BigInt support, so the benchmark fails +// gracefully during setup (the constructor will be undefined), instead of +// a hard fail when this file is loaded. +const typedArrayBigIntConstructors = [ + {name: "BigUint64", ctor: this["BigUint64Array"]}, + {name: "BigInt64", ctor: this["BigInt64Array"]} +]; diff --git a/deps/v8/test/js-perf-test/TypedArrays/join-bigint.js b/deps/v8/test/js-perf-test/TypedArrays/join-bigint.js new file mode 100644 index 0000000000..8f8bb92dbb --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/join-bigint.js @@ -0,0 +1,8 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('join.js'); + +new BenchmarkSuite('JoinBigIntTypes', [100], + CreateBenchmarks(typedArrayBigIntConstructors, false)); diff --git a/deps/v8/test/js-perf-test/TypedArrays/join-float.js b/deps/v8/test/js-perf-test/TypedArrays/join-float.js new file mode 100644 index 0000000000..e666bfda34 --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/join-float.js @@ -0,0 +1,8 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('join.js'); + +new BenchmarkSuite('JoinFloatTypes', [100], + CreateBenchmarks(typedArrayFloatConstructors, false)); diff --git a/deps/v8/test/js-perf-test/TypedArrays/join-int.js b/deps/v8/test/js-perf-test/TypedArrays/join-int.js new file mode 100644 index 0000000000..d08dc5f6ce --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/join-int.js @@ -0,0 +1,8 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('join.js'); + +new BenchmarkSuite('JoinIntTypes', [100], + CreateBenchmarks(typedArrayIntConstructors, false)); diff --git a/deps/v8/test/js-perf-test/TypedArrays/join-sep-bigint.js b/deps/v8/test/js-perf-test/TypedArrays/join-sep-bigint.js new file mode 100644 index 0000000000..34461b9395 --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/join-sep-bigint.js @@ -0,0 +1,8 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('join.js'); + +new BenchmarkSuite('JoinWithSeparatorBigIntTypes', [100], + CreateBenchmarks(typedArrayBigIntConstructors, true)); diff --git a/deps/v8/test/js-perf-test/TypedArrays/join-sep-float.js b/deps/v8/test/js-perf-test/TypedArrays/join-sep-float.js new file mode 100644 index 0000000000..672d2a6ff6 --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/join-sep-float.js @@ -0,0 +1,8 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('join.js'); + +new BenchmarkSuite('JoinWithSeparatorFloatTypes', [100], + CreateBenchmarks(typedArrayFloatConstructors, true)); diff --git a/deps/v8/test/js-perf-test/TypedArrays/join-sep-int.js b/deps/v8/test/js-perf-test/TypedArrays/join-sep-int.js new file mode 100644 index 0000000000..76312990ab --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/join-sep-int.js @@ -0,0 +1,8 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('join.js'); + +new BenchmarkSuite('JoinWithSeparatorIntTypes', [100], + CreateBenchmarks(typedArrayIntConstructors, true)); diff --git a/deps/v8/test/js-perf-test/TypedArrays/join.js b/deps/v8/test/js-perf-test/TypedArrays/join.js new file mode 100644 index 0000000000..9f090e4331 --- /dev/null +++ b/deps/v8/test/js-perf-test/TypedArrays/join.js @@ -0,0 +1,38 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +load('base.js'); + +function CreateBenchmarks(constructors, withSep) { + return constructors.map(({ ctor, name }) => + new Benchmark(`Join${name}`, false, false, 0, CreateJoinFn(withSep), + CreateSetupFn(ctor), TearDown) + ); +} + +const kInitialArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; +let result; +let arrayToJoin = []; + +function CreateSetupFn(constructor) { + return () => { + if (constructor == BigUint64Array || constructor == BigInt64Array) { + arrayToJoin = constructor.from(kInitialArray, x => BigInt(Math.floor(x))); + } else { + arrayToJoin = new constructor(kInitialArray); + } + } +} + +function CreateJoinFn(withSep) { + if (withSep) { + return () => result = arrayToJoin.join(','); + } else { + return () => result = arrayToJoin.join(''); + } +} + +function TearDown() { + arrayToJoin = void 0; +} diff --git a/deps/v8/test/js-perf-test/TypedArrays/sort.js b/deps/v8/test/js-perf-test/TypedArrays/sort.js index c2423994cd..c98ac05154 100644 --- a/deps/v8/test/js-perf-test/TypedArrays/sort.js +++ b/deps/v8/test/js-perf-test/TypedArrays/sort.js @@ -2,28 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -let typedArrayIntConstructors = [ - {name: "Uint8", ctor: Uint8Array}, - {name: "Int8", ctor: Int8Array}, - {name: "Uint16", ctor: Uint16Array}, - {name: "Int16", ctor: Int16Array}, - {name: "Uint32", ctor: Uint32Array}, - {name: "Int32", ctor: Int32Array}, - {name: "Uint8Clamped", ctor: Uint8ClampedArray}, -]; - -let typedArrayFloatConstructors = [ - {name: "Float32", ctor: Float32Array}, - {name: "Float64", ctor: Float64Array}, -]; - -// "ref" builds might not yet have BigInt support, so the benchmark fails -// gracefully during setup (the constructor will be undefined), instead of -// a hard fail when this file is loaded. -let typedArrayBigIntConstructors = [ - {name: "BigUint64", ctor: this["BigUint64Array"]}, - {name: "BigInt64", ctor: this["BigInt64Array"]} -]; +load('base.js'); function CreateBenchmarks(constructors, comparefns = []) { var benchmarks = []; diff --git a/deps/v8/test/js-perf-test/base.js b/deps/v8/test/js-perf-test/base.js index ca25789488..66a15c0ff9 100644 --- a/deps/v8/test/js-perf-test/base.js +++ b/deps/v8/test/js-perf-test/base.js @@ -105,7 +105,8 @@ BenchmarkSuite.ResetRNG = function() { Math.random = (function() { var seed = 49734321; return function() { - // Robert Jenkins' 32 bit integer hash function. + // Robert Jenkins' 32-bit integer hash function. + seed = seed & 0xffffffff; seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; |