Commit 8c171105 authored by Hai Dang's avatar Hai Dang Committed by Commit Bot

Enable warmup and/or longer runs for ArrayLiteralInitialSpread.

With warmup and/or longer runs, the benchmark results are more reliable.
This CL also splits the benchmark into smaller ones for easier management.

Change-Id: Ieba0734bef841d131b3184938109ca179994e173
Reviewed-on: https://chromium-review.googlesource.com/1188572Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Hai Dang <dhai@google.com>
Cr-Commit-Position: refs/heads/master@{#55422}
parent 5f225ebb
// 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 arrays.
const largeHoleyArray = new Array(100000);
const largeArray = Array.from(largeHoleyArray.keys());
// ----------------------------------------------------------------------------
// 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 + '-ArrayLiteralInitialSpreadLarge(Score): ' + result);
}
function PrintError(name, error) {
PrintResult('Error: ' + name, error);
success = false;
}
// Run the benchmark (20 x 100) iterations instead of 1 second.
function CreateBenchmark(name, f) {
new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 20, f) ]);
}
CreateBenchmark('Spread', SpreadLarge);
CreateBenchmark('ForLength', ForLengthLarge);
CreateBenchmark('ForLengthEmpty', ForLengthEmptyLarge);
CreateBenchmark('Slice', SliceLarge);
CreateBenchmark('Slice0', Slice0Large);
CreateBenchmark('ConcatReceive', ConcatReceiveLarge);
CreateBenchmark('ConcatArg', ConcatArgLarge);
CreateBenchmark('ForOfPush', ForOfPushLarge);
CreateBenchmark('MapId', MapIdLarge);
BenchmarkSuite.config.doWarmup = true;
BenchmarkSuite.config.doDeterministic = true;
BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError});
// 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 arrays.
const largeHoleyArray = new Array(100000);
for (var i = 0; i < 100; i++) {
largeHoleyArray[i] = i;
}
for (var i = 5000; i < 5500; i++) {
largeHoleyArray[i] = i;
}
// ----------------------------------------------------------------------------
// 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 + '-ArrayLiteralInitialSpreadLargeHoley(Score): ' + result);
}
function PrintError(name, error) {
PrintResult('Error: ' + name, error);
success = false;
}
// Run the benchmark (20 x 100) iterations instead of 1 second.
function CreateBenchmark(name, f) {
new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 20, f) ]);
}
CreateBenchmark('Spread', SpreadLargeHoley);
CreateBenchmark('ForLength', ForLengthLargeHoley);
CreateBenchmark('ForLengthEmpty', ForLengthEmptyLargeHoley);
CreateBenchmark('Slice', SliceLargeHoley);
CreateBenchmark('Slice0', Slice0LargeHoley);
CreateBenchmark('ConcatReceive', ConcatReceiveLargeHoley);
CreateBenchmark('ConcatArg', ConcatArgLargeHoley);
CreateBenchmark('ForOfPush', ForOfPushLargeHoley);
CreateBenchmark('MapId', MapIdLargeHoley);
BenchmarkSuite.config.doWarmup = true;
BenchmarkSuite.config.doDeterministic = true;
BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError});
// 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 arrays.
const smallHoleyArray = Array(100);
const smallArray = Array.from(Array(100).keys());
// ----------------------------------------------------------------------------
// 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 + '-ArrayLiteralInitialSpreadSmall(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});
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Comparing different copy schemes against spread initial literals // Comparing different copy schemes against spread initial literals.
// Benchmarks for small holey arrays.
const smallHoleyArray = Array(100); const smallHoleyArray = Array(100);
const smallArray = Array.from(Array(100).keys());
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
smallHoleyArray[i] = i; smallHoleyArray[i] = i;
...@@ -14,35 +14,10 @@ for (var i = 90; i < 99; i++) { ...@@ -14,35 +14,10 @@ for (var i = 90; i < 99; i++) {
smallHoleyArray[i] = i; smallHoleyArray[i] = i;
} }
const largeHoleyArray = new Array(100000);
const largeArray = Array.from(largeHoleyArray.keys());
for (var i = 0; i < 100; i++) {
largeHoleyArray[i] = i;
}
for (var i = 5000; i < 5500; i++) {
largeHoleyArray[i] = i;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Benchmark: Spread // Benchmark: Spread
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function SpreadSmall() {
var newArr = [...smallArray];
// basic sanity check
if (newArr.length != smallArray.length) throw 666;
return newArr;
}
function SpreadLarge() {
var newArr = [...largeArray];
// basic sanity check
if (newArr.length != largeArray.length) throw 666;
return newArr;
}
function SpreadSmallHoley() { function SpreadSmallHoley() {
var newArr = [...smallHoleyArray]; var newArr = [...smallHoleyArray];
// basic sanity check // basic sanity check
...@@ -50,37 +25,10 @@ function SpreadSmallHoley() { ...@@ -50,37 +25,10 @@ function SpreadSmallHoley() {
return newArr; return newArr;
} }
function SpreadLargeHoley() {
var newArr = [...largeHoleyArray];
// basic sanity check
if (newArr.length != largeHoleyArray.length) throw 666;
return newArr;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Benchmark: ForLength // 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;
}
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;
}
function ForLengthSmallHoley() { function ForLengthSmallHoley() {
var newArr = new Array(smallHoleyArray.length); var newArr = new Array(smallHoleyArray.length);
for (let i = 0; i < smallHoleyArray.length; i++) { for (let i = 0; i < smallHoleyArray.length; i++) {
...@@ -91,40 +39,10 @@ function ForLengthSmallHoley() { ...@@ -91,40 +39,10 @@ function ForLengthSmallHoley() {
return newArr; return newArr;
} }
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 // 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;
}
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;
}
function ForLengthEmptySmallHoley() { function ForLengthEmptySmallHoley() {
var newArr = []; var newArr = [];
for (let i = 0; i < smallHoleyArray.length; i++) { for (let i = 0; i < smallHoleyArray.length; i++) {
...@@ -135,34 +53,10 @@ function ForLengthEmptySmallHoley() { ...@@ -135,34 +53,10 @@ function ForLengthEmptySmallHoley() {
return newArr; return newArr;
} }
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 // Benchmark: Slice
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function SliceSmall() {
var newArr = smallArray.slice();
// basic sanity check
if (newArr.length != smallArray.length) throw 666;
return newArr;
}
function SliceLarge() {
var newArr = largeArray.slice();
// basic sanity check
if (newArr.length != largeArray.length) throw 666;
return newArr;
}
function SliceSmallHoley() { function SliceSmallHoley() {
var newArr = smallHoleyArray.slice(); var newArr = smallHoleyArray.slice();
// basic sanity check // basic sanity check
...@@ -170,31 +64,10 @@ function SliceSmallHoley() { ...@@ -170,31 +64,10 @@ function SliceSmallHoley() {
return newArr; return newArr;
} }
function SliceLargeHoley() {
var newArr = largeHoleyArray.slice();
// basic sanity check
if (newArr.length != largeHoleyArray.length) throw 666;
return newArr;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Benchmark: Slice0 // Benchmark: Slice0
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function Slice0Small() {
var newArr = smallArray.slice(0);
// basic sanity check
if (newArr.length != smallArray.length) throw 666;
return newArr;
}
function Slice0Large() {
var newArr = largeArray.slice(0);
// basic sanity check
if (newArr.length != largeArray.length) throw 666;
return newArr;
}
function Slice0SmallHoley() { function Slice0SmallHoley() {
var newArr = smallHoleyArray.slice(0); var newArr = smallHoleyArray.slice(0);
// basic sanity check // basic sanity check
...@@ -202,31 +75,10 @@ function Slice0SmallHoley() { ...@@ -202,31 +75,10 @@ function Slice0SmallHoley() {
return newArr; return newArr;
} }
function Slice0LargeHoley() {
var newArr = largeHoleyArray.slice(0);
// basic sanity check
if (newArr.length != largeHoleyArray.length) throw 666;
return newArr;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Benchmark: ConcatReceive // Benchmark: ConcatReceive
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function ConcatReceiveSmall() {
var newArr = smallArray.concat();
// basic sanity check
if (newArr.length != smallArray.length) throw 666;
return newArr;
}
function ConcatReceiveLarge() {
var newArr = largeArray.concat();
// basic sanity check
if (newArr.length != largeArray.length) throw 666;
return newArr;
}
function ConcatReceiveSmallHoley() { function ConcatReceiveSmallHoley() {
var newArr = smallHoleyArray.concat(); var newArr = smallHoleyArray.concat();
// basic sanity check // basic sanity check
...@@ -234,31 +86,10 @@ function ConcatReceiveSmallHoley() { ...@@ -234,31 +86,10 @@ function ConcatReceiveSmallHoley() {
return newArr; return newArr;
} }
function ConcatReceiveLargeHoley() {
var newArr = largeHoleyArray.concat();
// basic sanity check
if (newArr.length != largeHoleyArray.length) throw 666;
return newArr;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Benchmark: ConcatArg // Benchmark: ConcatArg
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function ConcatArgSmall() {
var newArr = [].concat(smallArray);
// basic sanity check
if (newArr.length != smallArray.length) throw 666;
return newArr;
}
function ConcatArgLarge() {
var newArr = [].concat(largeArray);
// basic sanity check
if (newArr.length != largeArray.length) throw 666;
return newArr;
}
function ConcatArgSmallHoley() { function ConcatArgSmallHoley() {
var newArr = [].concat(smallHoleyArray); var newArr = [].concat(smallHoleyArray);
// basic sanity check // basic sanity check
...@@ -266,37 +97,10 @@ function ConcatArgSmallHoley() { ...@@ -266,37 +97,10 @@ function ConcatArgSmallHoley() {
return newArr; return newArr;
} }
function ConcatArgLargeHoley() {
var newArr = [].concat(largeHoleyArray);
// basic sanity check
if (newArr.length != largeHoleyArray.length) throw 666;
return newArr;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Benchmark: ForOfPush // 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;
}
function ForOfPushLarge() {
var newArr = [];
for (let x of largeArray) {
newArr.push(x)
}
// basic sanity check
if (newArr.length != largeArray.length) throw 666;
return newArr;
}
function ForOfPushSmallHoley() { function ForOfPushSmallHoley() {
var newArr = []; var newArr = [];
for (let x of smallHoleyArray) { for (let x of smallHoleyArray) {
...@@ -307,34 +111,10 @@ function ForOfPushSmallHoley() { ...@@ -307,34 +111,10 @@ function ForOfPushSmallHoley() {
return newArr; return newArr;
} }
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 // Benchmark: MapId
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function MapIdSmall() {
var newArr = smallArray.map(x => x);
// basic sanity check
if (newArr.length != smallArray.length) throw 666;
return newArr;
}
function MapIdLarge() {
var newArr = largeArray.map(x => x);
// basic sanity check
if (newArr.length != largeArray.length) throw 666;
return newArr;
}
function MapIdSmallHoley() { function MapIdSmallHoley() {
var newArr = smallHoleyArray.map(x => x); var newArr = smallHoleyArray.map(x => x);
// basic sanity check // basic sanity check
...@@ -342,12 +122,6 @@ function MapIdSmallHoley() { ...@@ -342,12 +122,6 @@ function MapIdSmallHoley() {
return newArr; return newArr;
} }
function MapIdLargeHoley() {
var newArr = largeHoleyArray.map(x => x);
// basic sanity check
if (newArr.length != largeHoleyArray.length) throw 666;
return newArr;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Setup and Run // Setup and Run
...@@ -358,7 +132,7 @@ load('../base.js'); ...@@ -358,7 +132,7 @@ load('../base.js');
var success = true; var success = true;
function PrintResult(name, result) { function PrintResult(name, result) {
print(name + '-ArrayLiteralInitialSpread(Score): ' + result); print(name + '-ArrayLiteralInitialSpreadSmallHoley(Score): ' + result);
} }
function PrintError(name, error) { function PrintError(name, error) {
...@@ -370,50 +144,16 @@ function CreateBenchmark(name, f) { ...@@ -370,50 +144,16 @@ function CreateBenchmark(name, f) {
new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 0, f) ]); new BenchmarkSuite(name, [1000], [ new Benchmark(name, false, false, 0, f) ]);
} }
CreateBenchmark('Spread-Small', SpreadSmall); CreateBenchmark('Spread', SpreadSmallHoley);
CreateBenchmark('ForLength-Small', ForLengthSmall); CreateBenchmark('ForLength', ForLengthSmallHoley);
CreateBenchmark('ForLengthEmpty-Small', ForLengthEmptySmall); CreateBenchmark('ForLengthEmpty', ForLengthEmptySmallHoley);
CreateBenchmark('Slice-Small', SliceSmall); CreateBenchmark('Slice', SliceSmallHoley);
CreateBenchmark('Slice0-Small', Slice0Small); CreateBenchmark('Slice0', Slice0SmallHoley);
CreateBenchmark('ConcatReceive-Small', ConcatReceiveSmall); CreateBenchmark('ConcatReceive', ConcatReceiveSmallHoley);
CreateBenchmark('ConcatArg-Small', ConcatArgSmall); CreateBenchmark('ConcatArg', ConcatArgSmallHoley);
CreateBenchmark('ForOfPush-Small', ForOfPushSmall); CreateBenchmark('ForOfPush', ForOfPushSmallHoley);
CreateBenchmark('MapId-Small', MapIdSmall); CreateBenchmark('MapId', MapIdSmallHoley);
CreateBenchmark('Spread-Large', SpreadLarge);
CreateBenchmark('ForLength-Large', ForLengthLarge);
CreateBenchmark('ForLengthEmpty-Large', ForLengthEmptyLarge);
CreateBenchmark('Slice-Large', SliceLarge);
CreateBenchmark('Slice0-Large', Slice0Large);
CreateBenchmark('ConcatReceive-Large', ConcatReceiveLarge);
CreateBenchmark('ConcatArg-Large', ConcatArgLarge);
CreateBenchmark('ForOfPush-Large', ForOfPushLarge);
CreateBenchmark('MapId-Large', MapIdLarge);
CreateBenchmark('Spread-SmallHoley', SpreadSmallHoley);
CreateBenchmark('ForLength-SmallHoley', ForLengthSmallHoley);
CreateBenchmark('ForLengthEmpty-SmallHoley', ForLengthEmptySmallHoley);
CreateBenchmark('Slice-SmallHoley', SliceSmallHoley);
CreateBenchmark('Slice0-SmallHoley', Slice0SmallHoley);
CreateBenchmark('ConcatReceive-SmallHoley', ConcatReceiveSmallHoley);
CreateBenchmark('ConcatArg-SmallHoley', ConcatArgSmallHoley);
CreateBenchmark('ForOfPush-SmallHoley', ForOfPushSmallHoley);
CreateBenchmark('MapId-SmallHoley', MapIdSmallHoley);
CreateBenchmark('Spread-LargeHoley', SpreadLargeHoley);
CreateBenchmark('ForLength-LargeHoley', ForLengthLargeHoley);
CreateBenchmark('ForLengthEmpty-LargeHoley', ForLengthEmptyLargeHoley);
CreateBenchmark('Slice-LargeHoley', SliceLargeHoley);
CreateBenchmark('Slice0-LargeHoley', Slice0LargeHoley);
CreateBenchmark('ConcatReceive-LargeHoley', ConcatReceiveLargeHoley);
CreateBenchmark('ConcatArg-LargeHoley', ConcatArgLargeHoley);
CreateBenchmark('ForOfPush-LargeHoley', ForOfPushLargeHoley);
CreateBenchmark('MapId-LargeHoley', MapIdLargeHoley);
BenchmarkSuite.config.doWarmup = undefined; BenchmarkSuite.config.doWarmup = true;
BenchmarkSuite.config.doDeterministic = undefined; BenchmarkSuite.config.doDeterministic = false;
BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError}); BenchmarkSuite.RunSuites({NotifyResult: PrintResult, NotifyError: PrintError});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment