Commit 3fba4b70 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[js-perf-test] Add microbenchmarks for Array.prototype.join/toString.

Bug: v8:1956
Change-Id: Ic4c67392af2337ac35f9473073dae01264c5ac00
Reviewed-on: https://chromium-review.googlesource.com/590428Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46957}
parent 222aceab
// 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.
function benchy(name, test, testSetup) {
new BenchmarkSuite(name, [1000],
[
new Benchmark(name, false, false, 0, test, testSetup, ()=>{})
]);
}
benchy('SmiJoin', SmiJoin, SmiJoinSetup);
benchy('SmiJoin', SmiJoin, SmiJoinSetup);
benchy('SparseSmiJoin', SparseSmiJoin, SparseSmiJoinSetup);
benchy('SparseStringJoin', SparseStringJoin, SparseStringJoinSetup);
var array;
var result;
var array_size = 1000;
// Although these functions have the same code, they are separated for
// clean IC feedback.
function SmiJoin() {
result = array.join();
}
function StringJoin() {
result = array.join();
}
function SparseSmiJoin() {
result = array.join();
}
function SparseStringJoin() {
result = array.join();
}
function SmiJoinSetup() {
array = new Array();
for (var i = 0; i < array_size; ++i) array[i] = i;
}
function StringJoinSetup() {
array = new Array();
for (var i = 0; i < array_size; ++i) array[i] = `Item no. ${i}`;
}
function SparseSmiJoinSetup() {
SmiJoinSetup();
array.length = array.length * 2;
}
function SparseStringJoinSetup() {
StringJoinSetup();
array.length = array.length * 2;
}
......@@ -8,9 +8,11 @@ load('../base.js');
load('filter.js');
load('map.js');
load('every.js');
load('join.js');
load('some.js');
load('reduce.js');
load('reduce-right.js');
load('to-string.js');
var success = true;
......
// 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.
function benchy(name, test, testSetup) {
new BenchmarkSuite(name, [1000],
[
new Benchmark(name, false, false, 0, test, testSetup, ()=>{})
]);
}
benchy('SmiToString', SmiToString, SmiToStringSetup);
benchy('SmiToString', SmiToString, SmiToStringSetup);
benchy('SparseSmiToString', SparseSmiToString, SparseSmiToStringSetup);
benchy('SparseStringToString', SparseStringToString, SparseStringToStringSetup);
var array;
var result;
var array_size = 1000;
// Although these functions have the same code, they are separated for
// clean IC feedback.
function SmiToString() {
result = array.toString();
}
function StringToString() {
result = array.toString();
}
function SparseSmiToString() {
result = array.toString();
}
function SparseStringToString() {
result = array.toString();
}
function SmiToStringSetup() {
array = new Array();
for (var i = 0; i < array_size; ++i) array[i] = i;
}
function StringToStringSetup() {
array = new Array();
for (var i = 0; i < array_size; ++i) array[i] = `Item no. ${i}`;
}
function SparseSmiToStringSetup() {
SmiToStringSetup();
array.length = array.length * 2;
}
function SparseStringToStringSetup() {
StringToStringSetup();
array.length = array.length * 2;
}
......@@ -334,7 +334,8 @@
"path": ["Array"],
"main": "run.js",
"resources": [
"filter.js", "map.js", "every.js", "some.js", "reduce.js", "reduce-right.js"
"filter.js", "map.js", "every.js", "join.js", "some.js",
"reduce.js", "reduce-right.js", "to-string.js"
],
"flags": [
"--allow-natives-syntax"
......@@ -358,6 +359,10 @@
{"name": "FastEvery"},
{"name": "ObjectEvery"},
{"name": "OptFastEvery"},
{"name": "SmiJoin"},
{"name": "StringJoin"},
{"name": "SparseSmiJoin"},
{"name": "SparseStringJoin"},
{"name": "DoubleSome"},
{"name": "SmiSome"},
{"name": "FastSome"},
......@@ -372,7 +377,11 @@
{"name": "SmiReduceRight"},
{"name": "FastReduceRight"},
{"name": "ObjectReduceRight"},
{"name": "OptFastReduceRight"}
{"name": "OptFastReduceRight"},
{"name": "SmiToString"},
{"name": "StringToString"},
{"name": "SparseSmiToString"},
{"name": "SparseStringToString"}
]
},
{
......
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