3fba4b7089
Bug: v8:1956 Change-Id: Ic4c67392af2337ac35f9473073dae01264c5ac00 Reviewed-on: https://chromium-review.googlesource.com/590428 Reviewed-by: Georg Neis <neis@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#46957}
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
// 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;
|
|
}
|