Andrew Top | 63c7ad4 | 2019-11-25 16:10:13 -0800 | [diff] [blame] | 1 | // 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 | |
| 5 | load('sort-base.js'); |
| 6 | |
| 7 | function SortAsc() { |
| 8 | array_to_sort.sort(cmp_smaller); |
| 9 | } |
| 10 | |
| 11 | function 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 | |
| 19 | function 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 | |
| 27 | function CreateSortSuitesForLength(length) { |
| 28 | createSortSuite('Random' + length, 1000, SortAsc, () => Random(length)); |
| 29 | createSortSuite('Sorted' + length, 1000, SortAsc, () => Sorted(length)); |
| 30 | } |
| 31 | |
| 32 | CreateSortSuitesForLength(10); |
| 33 | CreateSortSuitesForLength(100); |
| 34 | CreateSortSuitesForLength(1000); |
| 35 | CreateSortSuitesForLength(10000); |
| 36 | CreateSortSuitesForLength(100000); |