Commit c6f800fd authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[jstest] Add random data configuration to ArraySortPreSorted

This CL adds sorting of a randomized array to the PreSorted benchmark
to act as a baseline/reference point.

R=jgruber@chromium.org

Bug: v8:7382
Change-Id: I45b77a6584d5d9a4f14a807f3796af7197673eaa
Reviewed-on: https://chromium-review.googlesource.com/1109508Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Simon Zünd <szuend@google.com>
Cr-Commit-Position: refs/heads/master@{#53913}
parent ef1031be
......@@ -57,6 +57,12 @@ function SawSeq3(a, tooth, length) {
}
}
function Random(a, length) {
for (let i = 0; i < length; ++i) {
a.push(Math.floor(Math.random() * length));
}
}
function TearDown() {
// Sanity check that the array is sorted.
let length = array_to_sort.length - 1;
......@@ -85,6 +91,8 @@ let SetupUpUp = () => SetupPreSortedHalfs(Up, Up);
let SetupDownDown = () => SetupPreSortedHalfs(Down, Down);
let SetupDownUp = () => SetupPreSortedHalfs(Down, Up);
createSortSuite(
'Random', 1000, SortAsc, () => Random(array_to_sort, kLength), TearDown);
createSortSuite(
'Up', 1000, SortAsc, () => Up(array_to_sort, kLength), TearDown);
createSortSuite(
......
......@@ -781,6 +781,7 @@
"--allow-natives-syntax"
],
"tests": [
{"name": "Random"},
{"name": "Up"},
{"name": "Down"},
{"name": "Saw1000"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment