blob: f27805a0efe307325d85ee25014caf2000160463 [file] [log] [blame]
Andrew Top63c7ad42019-11-25 16:10:13 -08001// Copyright 2018 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5load('sort-base.js');
6
7function SortAsc() {
8 array_to_sort.sort(cmp_smaller);
9}
10
11function Random(length) {
12 array_to_sort = [];
13 for (let i = 0; i < length; ++i) {
14 array_to_sort.push(Math.floor(Math.random() * length));
15 }
16 AssertPackedSmiElements();
17}
18
19function Sorted(length) {
20 array_to_sort = [];
21 for (let i = 0; i < length; ++i) {
22 array_to_sort.push(i);
23 }
24 AssertPackedSmiElements();
25}
26
27function CreateSortSuitesForLength(length) {
28 createSortSuite('Random' + length, 1000, SortAsc, () => Random(length));
29 createSortSuite('Sorted' + length, 1000, SortAsc, () => Sorted(length));
30}
31
32CreateSortSuitesForLength(10);
33CreateSortSuitesForLength(100);
34CreateSortSuitesForLength(1000);
35CreateSortSuitesForLength(10000);
36CreateSortSuitesForLength(100000);