a0ab7d4527
The (numbing) repetition in these tests were leading to errors when writing new tests. Now a function DefineHigherOrderTests() can be used to succinctly describe a test on (mostly) a single line. Change-Id: I70d65ffd784a17bbf0b9ca2de477135c5d901794 Reviewed-on: https://chromium-review.googlesource.com/864144 Commit-Queue: Michael Stanton <mvstanton@chromium.org> Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#50590}
40 lines
1015 B
JavaScript
40 lines
1015 B
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 make_tostring() {
|
|
return new Function("result = array.toString();");
|
|
}
|
|
|
|
benchy('SmiToString', make_tostring(), SmiToStringSetup);
|
|
benchy('StringToString', make_tostring(), StringToStringSetup);
|
|
benchy('SparseSmiToString', make_tostring(), SparseSmiToStringSetup);
|
|
benchy('SparseStringToString', make_tostring(), SparseStringToStringSetup);
|
|
|
|
var array;
|
|
var result;
|
|
var array_size = 1000;
|
|
|
|
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;
|
|
}
|
|
|
|
})();
|