v8/test/js-perf-test/ArraySort/sort-lengths.js
Simon Zünd 27040aac02 [jstest] Fix ElementsKind of the array that gets sorted
This CL fixes the "sort-lengths" benchmark so the ElementsKind of the
array to sort is PACKED_SMI again. This was somehow broken.

R=jgruber@chromium.org

Change-Id: I129e001eae4c88e9f99174b3494193232d933c3f
Reviewed-on: https://chromium-review.googlesource.com/1188122
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Simon Zünd <szuend@google.com>
Cr-Commit-Position: refs/heads/master@{#55371}
2018-08-24 07:35:07 +00:00

37 lines
942 B
JavaScript

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