[jstest] Add benchmarks that sort arrays of different lengths

All other sorting benchmarks use arrays of roughly the same length.
This CL adds a set of benchmarks that sort arrays of various lengths.

Two data configurations are used for each length: Completely random
and already sorted.

R=jgruber@chromium.org

Bug: v8:7382
Change-Id: Ib80a3421a68029c8e4f823605bab7b2d7fe1ae34
Reviewed-on: https://chromium-review.googlesource.com/1109509
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53917}
This commit is contained in:
Simon Zünd 2018-06-21 12:49:16 +02:00 committed by Commit Bot
parent 1834bbf7ec
commit c6d5179bad
2 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,40 @@
// 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('sort-base.js');
function SortAsc() {
array_to_sort.sort(cmp_smaller);
}
function Random(length) {
for (let i = 0; i < length; ++i) {
array_to_sort.push(Math.floor(Math.random()) * length);
}
AssertPackedSmiElements();
}
function Sorted(length) {
for (let i = 0; i < length; ++i) {
array_to_sort.push(i);
}
AssertPackedSmiElements();
}
function TearDown() {
array_to_sort = [];
}
function CreateSortSuitesForLength(length) {
createSortSuite(
'Random' + length, 1000, SortAsc, () => Random(length), TearDown);
createSortSuite(
'Sorted' + length, 1000, SortAsc, () => Sorted(length), TearDown);
}
CreateSortSuitesForLength(10);
CreateSortSuitesForLength(100);
CreateSortSuitesForLength(1000);
CreateSortSuitesForLength(10000);
CreateSortSuitesForLength(100000);

View File

@ -810,6 +810,29 @@
{"name": "MultipleCompareFns"}
]
},
{
"name": "ArraySortDifferentLengths",
"path": ["ArraySort"],
"main": "run.js",
"resources": ["sort-base.js", "sort-lengths.js"],
"test_flags": ["sort-lengths"],
"results_regexp": "^%s\\-ArraySort\\(Score\\): (.+)$",
"flags": [
"--allow-natives-syntax"
],
"tests": [
{"name": "Random10"},
{"name": "Sorted10"},
{"name": "Random100"},
{"name": "Sorted100"},
{"name": "Random1000"},
{"name": "Sorted1000"},
{"name": "Random10000"},
{"name": "Sorted10000"},
{"name": "Random100000"},
{"name": "Sorted100000"}
]
},
{
"name": "ForLoops",
"path": ["ForLoops"],