Commit d36f14a7 authored by caitp's avatar caitp Committed by Commit bot

[tests] add microbenchmark for %TypedArray%.prototype.copyWithin

Add a simple microbenchmark for calling copyWithin on a moderately large
Float64Array with 10,000 elements.

BUG=v8:5925, v8:5929, v8:4648
R=cbruni@chromium.org, adamk@chromium.org, littledan@chromium.org

Review-Url: https://codereview.chromium.org/2676193002
Cr-Commit-Position: refs/heads/master@{#42944}
parent 84b9c630
......@@ -274,6 +274,18 @@
{"name": "Object.hasOwnProperty--el-str"},
{"name": "Object.hasOwnProperty--NE-el"}
]
},
{
"name": "TypedArrays",
"path": ["TypedArrays"],
"main": "run.js",
"resources": [
"typedarrays.js"
],
"results_regexp": "^TypedArrays\\-%s\\(Scope\\): (.+)$",
"tests": [
{"name": "CopyWithin"}
]
}
]
}
// Copyright 2014 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('../base.js');
load('typedarrays.js');
var success = true;
function PrintResult(name, result) {
print(`TypedArrays-${name}(Score): ${result}`);
}
function PrintError(name, error) {
PrintResult(name, error);
success = false;
}
BenchmarkSuite.config.doWarmup = undefined;
BenchmarkSuite.config.doDeterministic = undefined;
BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
NotifyError: PrintError });
// 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('CopyWithin', [1000], [
new Benchmark('CopyWithin-Large', false, false, 0,
CopyWithinLarge, CopyWithinLargeSetup, CopyWithinLargeTearDown),
]);
var initialLargeFloat64Array = new Array(10000);
for (var i = 0; i < 5000; ++i) {
initialLargeFloat64Array[i] = i;
}
initialLargeFloat64Array = new Float64Array(initialLargeFloat64Array);
var largeFloat64Array;
function CopyWithinLarge() {
largeFloat64Array.copyWithin(5000);
}
function CopyWithinLargeSetup() {
largeFloat64Array = new Float64Array(initialLargeFloat64Array);
}
function CopyWithinLargeTearDown() {
for (var i = 0; i < 5000; ++i) {
if (largeFloat64Array[i + 5000] !== i) {
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