[mjsunit] Speed up array-concat.js test by not checking the entire array
This test creates an array that is 500000 elements long. Calling assertEquals on this with another array is really slow, especially on simulator runs. Most of this array is empty, only the first few elements and last few elements contain meaningful items, so we check those specific indices. On a local run this test goes from ~250s (--jitless) or ~111s to <1s. out/arm64.build/d8 --test test/mjsunit/mjsunit.js test/mjsunit/array-concat.js --random-seed=1 --nohard-abort --testing-d8-test-runner [--jitless] (using --jitless makes the test even slower) Bug: v8:7783 Change-Id: I660d3a9f1b3fe3afaa58fce28f493641059ba226 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2504853 Commit-Queue: Zhi An Ng <zhin@chromium.org> Reviewed-by: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/master@{#70825}
This commit is contained in:
parent
49001e0cbc
commit
22fead0c84
@ -225,15 +225,31 @@ assertEquals([undefined,2,1,3,"X"], r2);
|
||||
|
||||
// Make first array change length of second array massively.
|
||||
arr2.length = 2;
|
||||
var largeLength = 500000;
|
||||
Object.defineProperty(arr1, 0, {get: function() {
|
||||
arr2[500000] = "X";
|
||||
arr2[largeLength] = "X";
|
||||
return undefined;
|
||||
}, configurable: true})
|
||||
var r3 = [].concat(arr1, arr2); // [undefined,2,1,3,"X"]
|
||||
var expected = [undefined,2,1,3];
|
||||
expected[500000 + 2] = "X";
|
||||
var initialLen = expected.length;
|
||||
expected[largeLength + 2] = "X";
|
||||
|
||||
assertEquals(expected, r3);
|
||||
var numElementsToCheck = 10;
|
||||
|
||||
// Checking entire massive array is too slow, so check:
|
||||
var slicesToCheck = [
|
||||
// - the first few elements,
|
||||
{start: 0, end: initialLen},
|
||||
// - arbitrary number of elements past the first few elements,
|
||||
{start: initialLen, end: initialLen + numElementsToCheck},
|
||||
// - arbitrary number of elements in the middle of the array
|
||||
{start: largeLength / 2, end: largeLength / 2 + numElementsToCheck},
|
||||
// - last few elements
|
||||
{start: largeLength, end: largeLength + 3}];
|
||||
for (const {start, end} of slicesToCheck) {
|
||||
assertEquals(expected.slice(start, end), r3.slice(start, end));
|
||||
}
|
||||
|
||||
var arr3 = [];
|
||||
var trace = [];
|
||||
|
Loading…
Reference in New Issue
Block a user