[js-perf-tests] Create tests for Array.from

Modify "run_perf.py --filter Array/" so that it will let match "Array" but
not "ArrayLiteralSpread". Previously --filter Array/ would match nothing.

Change-Id: I1f9c677e3558fc2256a71306af5fc1a8394ac698
Reviewed-on: https://chromium-review.googlesource.com/895453
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51098}
This commit is contained in:
Dan Elphick 2018-02-05 15:53:36 +00:00 committed by Commit Bot
parent 56088a2659
commit 544c970534
4 changed files with 168 additions and 4 deletions

View File

@ -0,0 +1,153 @@
// 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.
(() => {
benchy('MixedFrom', MixedFrom, MixedFromSetup);
benchy('SmiFrom', SmiFrom, SmiFromSetup);
benchy('SmallSmiFrom', SmallSmiFrom, SmallSmiFromSetup);
benchy('SmiNoMapFrom', SmiNoMapFrom, SmiNoMapFromSetup);
benchy('SmiNoIteratorFrom', SmiNoIteratorFrom, SmiNoIteratorFromSetup);
benchy('TransplantedFrom', TransplantedFrom, TransplantedFromSetup);
benchy('DoubleFrom', DoubleFrom, DoubleFromSetup);
benchy('StringFrom', StringFrom, StringFromSetup);
benchy('StringNoMapFrom', StringNoMapFrom, StringNoMapFromSetup);
function ArrayLike() {}
ArrayLike.from = Array.from;
var arg
var result;
var func
var smi_array = [
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
];
var double_array = [
1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,
11.5,12.5,13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,
1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,
11.5,12.5,13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,
1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,
11.5,12.5,13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,
1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,
11.5,12.5,13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,
1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,
11.5,12.5,13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,
];
var string_array = [
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
];
var mixed_array = [
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,
11.5,12.5,13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,
1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,
11.5,12.5,13.5,14.5,15.5,16.5,17.5,18.5,19.5,20.5,
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
"a", "b", "c", "a", "b", "c", "a", "b", "c", "a",
]
// Although these functions have the same code, they are separated for
// clean IC feedback.
function SmallSmiFrom() {
result = Array.from(arg, func);
}
function SmiNoMapFrom() {
result = Array.from(arg);
}
function SmiFrom() {
result = Array.from(arg, func);
}
function SmiNoIteratorFrom() {
result = Array.from(arg, func);
}
function TransplantedFrom() {
result = ArrayLike.from(arg, func);
}
function DoubleFrom() {
result = Array.from(arg, func);
}
function StringFrom() {
result = Array.from(arg, func);
}
function StringNoMapFrom() {
result = Array.from(arg);
}
function MixedFrom() {
result = Array.from(arg, func);
}
function SmallSmiFromSetup() {
func = (v,i) => v + i;
arg = [1,2,3];
}
function SmiNoMapFromSetup() {
func = undefined;
arg = smi_array;
}
function SmiFromSetup() {
func = (v,i) => v + i;
arg = smi_array;
}
function SmiNoIteratorFromSetup() {
func = (v,i) => v + i;
array = smi_array;
arg = {length: array.length}
Object.assign(arg, array);
}
function TransplantedFromSetup() {
func = (v,i) => v + i;
arg = smi_array;
}
function DoubleFromSetup() {
func = (v,i) => v + i;
arg = double_array;
}
function StringFromSetup() {
func = (v,i) => v + i;
arg = string_array;
}
function StringNoMapFromSetup() {
func = undefined;
arg = string_array;
}
function MixedFromSetup() {
func = (v,i) => v + i;
arg = mixed_array;
}
})();

View File

@ -77,9 +77,10 @@ load('reduce.js');
load('reduce-right.js'); load('reduce-right.js');
load('find.js'); load('find.js');
load('find-index.js'); load('find-index.js');
load('of.js');
// Other Array builtins. // Other Array builtins.
load('from.js');
load('of.js');
load('join.js'); load('join.js');
load('to-string.js'); load('to-string.js');

View File

@ -417,7 +417,7 @@
"resources": [ "resources": [
"filter.js", "map.js", "every.js", "join.js", "some.js", "filter.js", "map.js", "every.js", "join.js", "some.js",
"reduce.js", "reduce-right.js", "to-string.js", "find.js", "reduce.js", "reduce-right.js", "to-string.js", "find.js",
"find-index.js", "of.js" "find-index.js", "from.js", "of.js"
], ],
"flags": [ "flags": [
"--allow-natives-syntax" "--allow-natives-syntax"
@ -493,7 +493,16 @@
{"name": "SmallTransplantedArrayOf"}, {"name": "SmallTransplantedArrayOf"},
{"name": "SmallDoubleArrayOf"}, {"name": "SmallDoubleArrayOf"},
{"name": "SmallStringArrayOf"}, {"name": "SmallStringArrayOf"},
{"name": "SmallMixedArrayOf"} {"name": "SmallMixedArrayOf"},
{"name": "SmiArrayFrom"},
{"name": "SmallSmiArrayFrom"},
{"name": "SmiArrayNoMapFrom"},
{"name": "SmiArrayNoIteratorFrom"},
{"name": "TransplantedArrayFrom"},
{"name": "DoubleArrayFrom"},
{"name": "StringArrayFrom"},
{"name": "StringArrayNoMapFrom"},
{"name": "MixedArrayFrom"}
] ]
}, },
{ {

View File

@ -1116,7 +1116,8 @@ def Main(args):
# Traverse graph/trace tree and iterate over all runnables. # Traverse graph/trace tree and iterate over all runnables.
for runnable in FlattenRunnables(root, NodeCB): for runnable in FlattenRunnables(root, NodeCB):
runnable_name = "/".join(runnable.graphs) runnable_name = "/".join(runnable.graphs)
if not runnable_name.startswith(options.filter): if (not runnable_name.startswith(options.filter) and
runnable_name + "/" != options.filter):
continue continue
print ">>> Running suite: %s" % runnable_name print ">>> Running suite: %s" % runnable_name