Add benchmark for TypedArray.prototype.set

Add benchmark for TypedArray.prototype.set when
setting from another TypedArray with the same type.

Bug: v8:6704
Change-Id: Ibde60b17aa32fb9c8237b2ab766d2b2913e256d7
Reviewed-on: https://chromium-review.googlesource.com/613264
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Franziska Hinkelmann <franzih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47342}
This commit is contained in:
Franziska Hinkelmann 2017-08-14 15:45:11 +02:00 committed by Commit Bot
parent 6917f9a5b8
commit ae0a6f4b0c
3 changed files with 25 additions and 1 deletions

View File

@ -317,6 +317,7 @@ function TypedArraySetFromOverlappingTypedArray(target, source, offset) {
}
}
// 22.2.3.23%TypedArray%.prototype.set ( overloaded [ , offset ] )
DEFINE_METHOD_LEN(
GlobalTypedArray.prototype,
set(obj, offset) {
@ -328,7 +329,7 @@ DEFINE_METHOD_LEN(
}
switch (%TypedArraySetFastCases(this, obj, intOffset)) {
// These numbers should be synchronized with runtime.cc.
// These numbers should be synchronized with runtime-typedarray.cc.
case 0: // TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE
return;
case 1: // TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING

View File

@ -331,6 +331,12 @@
"resources": ["construct-all-typedarrays.js"],
"test_flags": ["construct-all-typedarrays"]
},
{
"name": "SetFromSameType",
"main": "run.js",
"resources": ["set-from-same-type.js"],
"test_flags": ["set-from-same-type"]
},
{
"name": "Sort",
"main": "run.js",

View File

@ -0,0 +1,17 @@
// 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('SetFromSameType', [1000], [
new Benchmark('SetFromSameType', false, false, 0, SetFromSameType),
]);
let src = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4];
let typed_src = new Float32Array(src);
let typed_dest = new Float32Array(16);
function SetFromSameType() {
typed_dest.set(typed_src);
}