Commit 0dbac434 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[js-perf-test] Make regress-2185-2 test into a benchmark.

The regression test 2185-2 measured the Array.p.sort time for various
pre-sorted data configurations. This CL adds the various data
configurations to the ArraySortPreSorted benchmark and removes the
regression test altogether.

R=cbruni@chromium.org, jgruber@chromium.org

Change-Id: I6e2eb235e4a7578f4a107229bfc6a9e89a3aa5e3
Reviewed-on: https://chromium-review.googlesource.com/1076188
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53420}
parent dd78d603
......@@ -4,16 +4,95 @@
load('sort-base.js');
function SetupPreSorted() {
CreatePackedSmiArray();
array_to_sort.sort();
const kLength = 2e4;
const kLengthHalf = kLength >>> 1;
function SortAsc() {
array_to_sort.sort(cmp_smaller);
}
function Up(a, length) {
for (let i = 0; i < length; ++i) {
a.push(i);
}
}
function Down(a, length) {
for (let i = 0; i < length; ++i) {
a.push(length - i);
}
}
function SawSeq(a, tooth, length) {
let count = 0;
while (true) {
for (let i = 0; i < tooth; ++i) {
a.push(i);
if (++count >= length) return;
}
}
}
function SetupPreSortedReversed() {
CreatePackedSmiArray();
array_to_sort.sort();
array_to_sort.reverse();
function SawSeq2(a, tooth, length) {
let count = 0;
while (true) {
for (let i = 0; i < tooth; ++i) {
a.push(i);
if (++count >= length) return;
}
for (let i = 0; i < tooth; ++i) {
a.push(tooth - i);
if (++count >= length) return;
}
}
}
createSuite('PackedSmiPreSorted', 1000, Sort, SetupPreSorted);
createSuite('PackedSmiPreSortedReversed', 1000, Sort, SetupPreSortedReversed);
function SawSeq3(a, tooth, length) {
let count = 0;
while (true) {
for (let i = 0; i < tooth; ++i) {
a.push(tooth - i);
if (++count >= length) return;
}
}
}
function TearDown() {
// Sanity check that the array is sorted.
let length = array_to_sort.length - 1;
for (let i = 0; i < length; ++i) {
if (array_to_sort[i] > array_to_sort[i + 1]) {
throw "Not sorted correctly: i = " + i;
}
}
array_to_sort = [];
}
let SetupSaw1000 = () => SawSeq(array_to_sort, 1000, kLength);
let SetupSaw500 = () => SawSeq(array_to_sort, 500, kLength);
let SetupSaw200 = () => SawSeq(array_to_sort, 200, kLength);
let SetupSaw200Sym = () => SawSeq2(array_to_sort, 200, kLength);
let SetupSaw200Down = () => SawSeq3(array_to_sort, 200, kLength);
function SetupPreSortedHalfs(firstfn, secondfn) {
array_to_sort = [];
firstfn(array_to_sort, kLengthHalf);
secondfn(array_to_sort, kLengthHalf);
}
let SetupUpDown = () => SetupPreSortedHalfs(Up, Down);
let SetupUpUp = () => SetupPreSortedHalfs(Up, Up);
let SetupDownDown = () => SetupPreSortedHalfs(Down, Down);
let SetupDownUp = () => SetupPreSortedHalfs(Down, Up);
createSuite('Up', 1000, SortAsc, () => Up(array_to_sort, kLength), TearDown);
createSuite('Down', 1000, SortAsc, () => Down(array_to_sort, kLength), TearDown);
createSuite('Saw1000', 1000, SortAsc, SetupSaw1000, TearDown);
createSuite('Saw500', 1000, SortAsc, SetupSaw500, TearDown);
createSuite('Saw200', 1000, SortAsc, SetupSaw200, TearDown);
createSuite('Saw200Symmetric', 1000, SortAsc, SetupSaw200Sym, TearDown);
createSuite('Saw200Down', 1000, SortAsc, SetupSaw200Down, TearDown);
createSuite('UpDown', 1000, SortAsc, SetupUpDown, TearDown);
createSuite('UpUp', 1000, SortAsc, SetupUpUp, TearDown);
createSuite('DownDown', 1000, SortAsc, SetupDownDown, TearDown);
createSuite('DownUp', 1000, SortAsc, SetupDownUp, TearDown);
......@@ -771,8 +771,17 @@
"--allow-natives-syntax"
],
"tests": [
{"name": "PackedSmiPreSorted"},
{"name": "PackedSmiPreSortedReversed"}
{"name": "Up"},
{"name": "Down"},
{"name": "Saw1000"},
{"name": "Saw500"},
{"name": "Saw200"},
{"name": "Saw200Symmetric"},
{"name": "Saw200Down"},
{"name": "UpDown"},
{"name": "UpUp"},
{"name": "DownDown"},
{"name": "DownUp"}
]
},
{
......
......@@ -67,7 +67,7 @@ function BenchmarkSuite(name, reference, benchmarks) {
function createSuite(name, count, test, testSetup, tearDown) {
return new BenchmarkSuite(name, [count], [
new Benchmark(name, false, false, 0, test, testSetup, tearDown]);
new Benchmark(name, false, false, 0, test, testSetup, tearDown)]);
}
function createSuiteWithWarmup(name, count, testSetup, tearDown) {
......
......@@ -361,7 +361,6 @@
'math-floor-of-div': [PASS, SLOW],
'messages': [PASS, SLOW],
'packed-elements': [PASS, SLOW],
'regress/regress-2185-2': [PASS, SLOW],
'regress/regress-2185': [PASS, SLOW],
'regress/regress-2790': [PASS, SLOW],
'regress/regress-331444': [PASS, SLOW],
......@@ -437,9 +436,6 @@
'harmony/regexp-property-lu-ui': [SKIP],
'regress/regress-165637': [SKIP],
# Flaky with baseline?
'regress/regress-2185-2': [SKIP],
# https://bugs.chromium.org/p/v8/issues/detail?id=7102
# Flaky due to huge string allocation.
'regress/regress-748069': [SKIP],
......@@ -501,7 +497,6 @@
'compiler/osr-with-args': [PASS, SLOW],
'lexicographic-compare': [PASS, SLOW],
'packed-elements': [PASS, SLOW],
'regress/regress-2185-2': [PASS, SLOW],
'regress/regress-2790': [PASS, SLOW],
'regress/regress-91008': [PASS, SLOW],
'regress/regress-json-stringify-gc': [PASS, SLOW],
......@@ -652,7 +647,6 @@
# Skip tests that are not suitable for deoptimization fuzzing.
'never-optimize': [SKIP],
'regress/regress-2185-2': [SKIP],
'readonly': [SKIP],
'array-feedback': [SKIP],
'deopt-recursive-eager-once': [SKIP],
......@@ -774,17 +768,8 @@
# Flaky crash on Odroid devices: https://crbug.com/v8/7678
'regress/regress-336820': [PASS, ['arch == arm and not simulator_run', SKIP]],
# Slow tests.
'regress/regress-2185-2': [SKIP],
}], # variant == stress
##############################################################################
['variant == nooptimization', {
# Slow tests.
'regress/regress-2185-2': [SKIP],
}], # variant == nooptimization
##############################################################################
['variant == nooptimization and (arch == arm or arch == arm64) and simulator_run', {
# Slow tests: https://crbug.com/v8/7783
......
// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// These tests used to time out before this was fixed.
var LEN = 2e4;
function short() {
var sum = 0;
for (var i = 0; i < 1000; i++) {
var a = [1, 4, 34, 23, 6, 123, 3, 2, 11, 515, 4, 33, 22, 2, 2, 1, 0, 123,
23, 42, 43, 1002, 44, 43, 101, 23, 55, 11, 101, 102, 45, 11, 404,
31415, 34, 53, 453, 45, 34, 5, 2, 35, 5, 345, 36, 45, 345, 3, 45,
3, 5, 5, 2, 2342344, 2234, 23, 2718, 1500, 2, 19, 22, 43, 41, 0,
-1, 33, 45, 78];
a.sort(function(a, b) { return a - b; });
sum += a[0];
}
return sum;
}
function short_bench(name, array) {
var start = new Date();
short();
var end = new Date();
var ms = end - start;
print("Short " + Math.floor(ms) + "ms");
}
function sawseq(a, tooth) {
var count = 0;
while (true) {
for (var i = 0; i < tooth; i++) {
a.push(i);
if (++count >= LEN) return a;
}
}
}
function sawseq2(a, tooth) {
var count = 0;
while (true) {
for (var i = 0; i < tooth; i++) {
a.push(i);
if (++count >= LEN) return a;
}
for (var i = 0; i < tooth; i++) {
a.push(tooth - i);
if (++count >= LEN) return a;
}
}
}
function sawseq3(a, tooth) {
var count = 0;
while (true) {
for (var i = 0; i < tooth; i++) {
a.push(tooth - i);
if (++count >= LEN) return a;
}
}
}
function up(a) {
for (var i = 0; i < LEN; i++) {
a.push(i);
}
return a;
}
function down(a) {
for (var i = 0; i < LEN; i++) {
a.push(LEN - i);
}
return a;
}
function ran(a) {
for (var i = 0; i < LEN; i++) {
a.push(Math.floor(Math.random() * LEN));
}
return a;
}
var random = ran([]);
var asc = up([]);
var desc = down([]);
var asc_desc = down(up([]));
var desc_asc = up(down([]));
var asc_asc = up(up([]));
var desc_desc = down(down([]));
var saw1 = sawseq([], 1000);
var saw2 = sawseq([], 500);
var saw3 = sawseq([], 200);
var saw4 = sawseq2([], 200);
var saw5 = sawseq3([], 200);
function bench(name, array) {
var start = new Date();
array.sort(function(a, b) { return a - b; });
var end = new Date();
for (var i = 0; i < array.length - 1; i++) {
if (array[i] > array[i + 1]) throw name + " " + i;
}
var ms = end - start;
print(name + " " + Math.floor(ms) + "ms");
}
short_bench();
bench("random", random);
bench("up", asc);
bench("down", desc);
bench("saw 1000", saw1);
bench("saw 500", saw2);
bench("saw 200", saw3);
bench("saw 200 symmetric", saw4);
bench("saw 200 down", saw4);
bench("up, down", asc_desc);
bench("up, up", asc_asc);
bench("down, down", desc_desc);
bench("down, up", desc_asc);
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