Commit 693b741f authored by cwhan.tunz's avatar cwhan.tunz Committed by Commit bot

[tests] Add js-perf-test for %TypedArray%.prototype.sort

- Add benchmark for sorting of Float64Array
- Rename existing typedarray.js to copywithin.js

BUG=v8:5953
R=bmeurer@chromium.org, caitp@chromium.org, petermarshall@chromium.org

Review-Url: https://codereview.chromium.org/2691423003
Cr-Commit-Position: refs/heads/master@{#43217}
parent b8787e34
......@@ -283,7 +283,7 @@
{
"name": "CopyWithin",
"main": "run.js",
"test_flags": ["typedarrays"]
"test_flags": ["copywithin"]
},
{
"name": "Constructor",
......@@ -296,6 +296,11 @@
"results_regexp": "^TypedArrays\\-Constructor\\(Score\\): (.+)$",
"main": "run.js",
"test_flags": ["constructor"]
},
{
"name": "Sort",
"main": "run.js",
"test_flags": ["sort"]
}
]
}
......
// Copyright 2017 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.
new BenchmarkSuite('Sort', [1000], [
new Benchmark('Sort', false, false, 0,
sortLarge, sortLargeSetup, sortLargeTearDown),
]);
var size = 3000;
var initialLargeFloat64Array = new Array(size);
for (var i = 0; i < size; ++i) {
initialLargeFloat64Array[i] = Math.random();
}
initialLargeFloat64Array = new Float64Array(initialLargeFloat64Array);
var largeFloat64Array;
function sortLarge() {
largeFloat64Array.sort();
}
function sortLargeSetup() {
largeFloat64Array = new Float64Array(initialLargeFloat64Array);
}
function sortLargeTearDown() {
for (var i = 0; i < size - 1; ++i) {
if (largeFloat64Array[i] > largeFloat64Array[i+1]) {
throw new TypeError("Unexpected result!\n" + largeFloat64Array);
}
}
largeFloat64Array = void 0;
}
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