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

Add TypedArray.p.sort benchmarks for BigInts.

This CL adds sort benchmarks for BigUint64Array and BigInt64Array.
They form their own benchmark group separate from the Int and
Float types/element kinds.

R=jgruber@chromium.org

Bug: v8:7382
Change-Id: Id3ce125be36a42c419a2632edc5f930547a1720e
Reviewed-on: https://chromium-review.googlesource.com/1016643Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Simon Zünd <szuend@google.com>
Cr-Commit-Position: refs/heads/master@{#52668}
parent c2280f9a
......@@ -537,6 +537,12 @@
"resources": ["sort.js", "sort-int.js"],
"test_flags": ["sort-int"]
},
{
"name": "SortBigIntTypes",
"main": "run.js",
"resources": ["sort.js", "sort-bigint.js"],
"test_flags": ["sort-bigint"]
},
{
"name": "SortFloatTypes",
"main": "run.js",
......@@ -549,6 +555,12 @@
"resources": ["sort.js", "sort-cmpfn-int.js"],
"test_flags": ["sort-cmpfn-int"]
},
{
"name": "SortCustomCompareFnBigIntTypes",
"main": "run.js",
"resources": ["sort.js", "sort-cmpfn-bigint.js"],
"test_flags": ["sort-cmpfn-bigint"]
},
{
"name": "SortCustomCompareFnFloatTypes",
"main": "run.js",
......
// 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.js');
new BenchmarkSuite('SortBigIntTypes', [1000],
CreateBenchmarks(typedArrayBigIntConstructors));
// 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.js');
new BenchmarkSuite('SortCustomCompareFnBigIntTypes', [1000],
CreateBenchmarks(typedArrayBigIntConstructors,
[cmp_smaller, cmp_greater]));
......@@ -17,6 +17,11 @@ let typedArrayFloatConstructors = [
{name: "Float64", ctor: Float64Array},
];
let typedArrayBigIntConstructors = [
{name: "BigUint64", ctor: BigUint64Array},
{name: "BigInt64", ctor: BigInt64Array}
];
function CreateBenchmarks(constructors, comparefns = []) {
var benchmarks = [];
for (let constructor of constructors) {
......@@ -27,17 +32,22 @@ function CreateBenchmarks(constructors, comparefns = []) {
return benchmarks;
}
const size = 3000;
const initialLargeArray = new Array(size);
for (let i = 0; i < size; ++i) {
initialLargeArray[i] = Math.random() * 3000;
const kArraySize = 3000;
const initialLargeArray = new Array(kArraySize);
for (let i = 0; i < kArraySize; ++i) {
initialLargeArray[i] = Math.random() * kArraySize;
}
let array_to_sort = [];
function CreateSetupFn(constructor) {
return () => {
array_to_sort = new constructor(initialLargeArray);
if (constructor == BigUint64Array || constructor == BigInt64Array) {
array_to_sort = constructor.from(initialLargeArray,
x => BigInt(Math.floor(x)));
} else {
array_to_sort = new constructor(initialLargeArray);
}
}
}
......
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