Commit 9679a366 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[test] Add a benchmark for constructing all types of TypedArrays.

This constructs different typed arrays from different types of other
typed arrays, hopefully countering microbenchmarks which are able to
optimize for exactly one pair of types.

Bug: v8:5977
Change-Id: Ie3b07d6ecaaca6db0be410e902e437a2a643d71c
Reviewed-on: https://chromium-review.googlesource.com/474748Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44576}
parent c1a9e556
......@@ -348,6 +348,12 @@
"resources": ["construct-same-typedarray.js"],
"test_flags": ["construct-same-typedarray"]
},
{
"name": "ConstructAllTypedArrays",
"main": "run.js",
"resources": ["construct-all-typedarrays.js"],
"test_flags": ["construct-all-typedarrays"]
},
{
"name": "Sort",
"main": "run.js",
......
// 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('ConstructAllTypedArrays', [1000], [
new Benchmark('ConstructAllTypedArrays', false, false, 0, constructor),
]);
var typedArrayConstructors = [
Uint8Array,
Int8Array,
Uint16Array,
Int16Array,
Uint32Array,
Int32Array,
Float32Array,
Float64Array,
Uint8ClampedArray
];
const length = 32;
let uint8_array = new Uint8Array(length);
let int32_array = new Int32Array(length);
let float32_array = new Float32Array(length);
let float64_array = new Float64Array(length);
for (var i = 0; i < length; i++) {
uint8_array[i] = i;
int32_array[i] = i;
float32_array[i] = i;
float64_array[i] = i;
}
function constructor() {
for (constructor of typedArrayConstructors) {
new constructor(uint8_array);
new constructor(int32_array);
new constructor(float32_array);
new constructor(float64_array);
}
}
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