2018-06-21 10:49:16 +00:00
|
|
|
// 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.
|
|
|
|
|
2021-06-01 12:46:36 +00:00
|
|
|
d8.file.execute('sort-base.js');
|
2018-06-21 10:49:16 +00:00
|
|
|
|
|
|
|
function SortAsc() {
|
|
|
|
array_to_sort.sort(cmp_smaller);
|
|
|
|
}
|
|
|
|
|
|
|
|
function Random(length) {
|
2018-08-24 06:50:32 +00:00
|
|
|
array_to_sort = [];
|
2018-06-21 10:49:16 +00:00
|
|
|
for (let i = 0; i < length; ++i) {
|
2018-08-23 08:52:51 +00:00
|
|
|
array_to_sort.push(Math.floor(Math.random() * length));
|
2018-06-21 10:49:16 +00:00
|
|
|
}
|
|
|
|
AssertPackedSmiElements();
|
|
|
|
}
|
|
|
|
|
|
|
|
function Sorted(length) {
|
2018-08-24 06:50:32 +00:00
|
|
|
array_to_sort = [];
|
2018-06-21 10:49:16 +00:00
|
|
|
for (let i = 0; i < length; ++i) {
|
|
|
|
array_to_sort.push(i);
|
|
|
|
}
|
|
|
|
AssertPackedSmiElements();
|
|
|
|
}
|
|
|
|
|
|
|
|
function CreateSortSuitesForLength(length) {
|
2018-08-24 06:50:32 +00:00
|
|
|
createSortSuite('Random' + length, 1000, SortAsc, () => Random(length));
|
|
|
|
createSortSuite('Sorted' + length, 1000, SortAsc, () => Sorted(length));
|
2018-06-21 10:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CreateSortSuitesForLength(10);
|
|
|
|
CreateSortSuitesForLength(100);
|
|
|
|
CreateSortSuitesForLength(1000);
|
|
|
|
CreateSortSuitesForLength(10000);
|
|
|
|
CreateSortSuitesForLength(100000);
|