Commit f728d698 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[js-perf-test] Consistently use createSuite in all benchmarks

Change-Id: I7bf0144bacd0572a42b98d0a0f19df3daf63128b
Bug: chromium:840785
Reviewed-on: https://chromium-review.googlesource.com/1051240
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53418}
parent 8b37b698
......@@ -3,151 +3,151 @@
// 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;
}
createSuite('MixedFrom', 1000, MixedFrom, MixedFromSetup);
createSuite('SmiFrom', 1000, SmiFrom, SmiFromSetup);
createSuite('SmallSmiFrom', 1000, SmallSmiFrom, SmallSmiFromSetup);
createSuite('SmiNoMapFrom', 1000, SmiNoMapFrom, SmiNoMapFromSetup);
createSuite(
'SmiNoIteratorFrom', 1000, SmiNoIteratorFrom, SmiNoIteratorFromSetup);
createSuite(
'TransplantedFrom', 1000, TransplantedFrom, TransplantedFromSetup);
createSuite('DoubleFrom', 1000, DoubleFrom, DoubleFromSetup);
createSuite('StringFrom', 1000, StringFrom, StringFromSetup);
createSuite('StringNoMapFrom', 1000, 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;
}
})();
......@@ -11,10 +11,10 @@ function make_join() {
return new Function('result = array.join();');
}
benchy('SmiJoin', make_join(), SmiJoinSetup);
benchy('StringJoin', make_join(), StringJoinSetup);
benchy('SparseSmiJoin', make_join(), SparseSmiJoinSetup);
benchy('SparseStringJoin', make_join(), SparseStringJoinSetup);
createSuite('SmiJoin', 1000, make_join(), SmiJoinSetup);
createSuite('StringJoin', 1000, make_join(), StringJoinSetup);
createSuite('SparseSmiJoin', 1000, make_join(), SparseSmiJoinSetup);
createSuite('SparseStringJoin', 1000, make_join(), SparseStringJoinSetup);
function SmiJoinSetup() {
array = new Array();
......
......@@ -3,115 +3,119 @@
// found in the LICENSE file.
(() => {
benchy('EmptyArrayOf', EmptyArrayOf, EmptyArrayOfSetup);
benchy('SmallTransplantedArrayOf', SmallTransplantedArrayOf,
SmallTransplantedArrayOfSetup);
benchy('SmallSmiArrayOf', SmallSmiArrayOf, SmallSmiArrayOfSetup);
benchy('LargeSmiArrayOf', LargeSmiArrayOf, LargeSmiArrayOfSetup);
benchy('SmallDoubleArrayOf', SmallDoubleArrayOf, SmallDoubleArrayOfSetup);
benchy('SmallStringArrayOf', SmallStringArrayOf, SmallStringArrayOfSetup);
benchy('SmallMixedArrayOf', SmallMixedArrayOf, SmallMixedArrayOfSetup);
function ArrayLike() {}
ArrayLike.of = Array.of;
var arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10
var arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20
var result;
function EmptyArrayOf() {
result = Array.of();
}
function BaselineArray() {
result = [arg1, arg2, arg3];
}
function SmallSmiArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function LargeSmiArrayOf() {
result = Array.of(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20);
}
function SmallTransplantedArrayOf() {
result = ArrayLike.of(arg1, arg2, arg3);
}
function SmallDoubleArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function SmallStringArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function SmallMixedArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function EmptyArrayOfSetup() {
}
function BaselineArraySetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
}
function SmallSmiArrayOfSetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
}
function SmallTransplantedArrayOfSetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
}
function SmallDoubleArrayOfSetup() {
arg1 = 1.5;
arg2 = 2.5;
arg3 = 3.5;
}
function SmallStringArrayOfSetup() {
arg1 = "cat";
arg2 = "dog";
arg3 = "giraffe";
}
function SmallMixedArrayOfSetup() {
arg1 = 1;
arg2 = 2.5;
arg3 = "giraffe";
}
function LargeSmiArrayOfSetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
arg4 = 4;
arg5 = 5;
arg6 = 6;
arg7 = 7;
arg8 = 8;
arg9 = 9;
arg10 = 10;
arg11 = 11;
arg12 = 12;
arg13 = 13;
arg14 = 14;
arg15 = 15;
arg16 = 16;
arg17 = 17;
arg18 = 18;
arg19 = 19;
arg20 = 20;
}
createSuite('EmptyArrayOf', 1000, EmptyArrayOf, EmptyArrayOfSetup);
createSuite(
'SmallTransplantedArrayOf', 1000, SmallTransplantedArrayOf,
SmallTransplantedArrayOfSetup);
createSuite('SmallSmiArrayOf', 1000, SmallSmiArrayOf, SmallSmiArrayOfSetup);
createSuite('LargeSmiArrayOf', 1000, LargeSmiArrayOf, LargeSmiArrayOfSetup);
createSuite(
'SmallDoubleArrayOf', 1000, SmallDoubleArrayOf, SmallDoubleArrayOfSetup);
createSuite(
'SmallStringArrayOf', 1000, SmallStringArrayOf, SmallStringArrayOfSetup);
createSuite(
'SmallMixedArrayOf', 1000, SmallMixedArrayOf, SmallMixedArrayOfSetup);
function ArrayLike() {}
ArrayLike.of = Array.of;
var arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10
var arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20
var result;
function EmptyArrayOf() {
result = Array.of();
}
function BaselineArray() {
result = [arg1, arg2, arg3];
}
function SmallSmiArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function LargeSmiArrayOf() {
result = Array.of(
arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11,
arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20);
}
function SmallTransplantedArrayOf() {
result = ArrayLike.of(arg1, arg2, arg3);
}
function SmallDoubleArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function SmallStringArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function SmallMixedArrayOf() {
result = Array.of(arg1, arg2, arg3);
}
function EmptyArrayOfSetup() {}
function BaselineArraySetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
}
function SmallSmiArrayOfSetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
}
function SmallTransplantedArrayOfSetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
}
function SmallDoubleArrayOfSetup() {
arg1 = 1.5;
arg2 = 2.5;
arg3 = 3.5;
}
function SmallStringArrayOfSetup() {
arg1 = 'cat';
arg2 = 'dog';
arg3 = 'giraffe';
}
function SmallMixedArrayOfSetup() {
arg1 = 1;
arg2 = 2.5;
arg3 = 'giraffe';
}
function LargeSmiArrayOfSetup() {
arg1 = 1;
arg2 = 2;
arg3 = 3;
arg4 = 4;
arg5 = 5;
arg6 = 6;
arg7 = 7;
arg8 = 8;
arg9 = 9;
arg10 = 10;
arg11 = 11;
arg12 = 12;
arg13 = 13;
arg14 = 14;
arg15 = 15;
arg16 = 16;
arg17 = 17;
arg18 = 18;
arg19 = 19;
arg20 = 20;
}
})();
......@@ -24,13 +24,6 @@ function mc(name, generic = false) {
return new Function(`result = array.${name}(func, this_arg);`);
}
function benchy(name, test, testSetup) {
new BenchmarkSuite(name, [1000],
[
new Benchmark(name, false, false, 0, test, testSetup, ()=>{})
]);
}
function SmiSetup() {
array = Array.from({ length: array_size }, (_, i) => i);
}
......@@ -63,7 +56,7 @@ function DefineHigherOrderTests(tests) {
this_arg = undefined;
setupFunc();
};
benchy(name, testFunc, setupFuncWrapper);
createSuite(name, 1000, testFunc, setupFuncWrapper);
}
}
......
......@@ -7,10 +7,11 @@ 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);
createSuite('SmiToString', 1000, make_tostring(), SmiToStringSetup);
createSuite('StringToString', 1000, make_tostring(), StringToStringSetup);
createSuite('SparseSmiToString', 1000, make_tostring(), SparseSmiToStringSetup);
createSuite(
'SparseStringToString', 1000, make_tostring(), SparseStringToStringSetup);
var array;
var result;
......
......@@ -5,13 +5,6 @@
load('../base.js');
load(arguments[0] + '.js')
function benchy(name, test, testSetup, testTearDown) {
new BenchmarkSuite(name, [1000],
[
new Benchmark(name, false, false, 0, test, testSetup, testTearDown)
]);
}
function PrintResult(name, result) {
print(name + '-ArraySort(Score): ' + result);
}
......
......@@ -23,17 +23,22 @@ let cmp_packed_smi_to_double = CreateCompareFn(() => array_to_sort.push(0.1));
let cmp_holey_smi_to_double = CreateCompareFn(() => array_to_sort.push(0.1));
let cmp_double_to_double = CreateCompareFn(() => array_to_sort.length *= 2);
benchy('PackedSmiToPackedDouble', CreateSortFn([cmp_packed_smi_to_double]),
CreatePackedSmiArray, AssertPackedDoubleElements);
benchy('HoleySmiToHoleyDouble', CreateSortFn([cmp_holey_smi_to_double]),
CreateHoleySmiArray, AssertHoleyDoubleElements);
benchy('PackedDoubleToHoleyDouble', CreateSortFn([cmp_double_to_double]),
CreatePackedDoubleArray, AssertHoleyDoubleElements);
createSuite(
'PackedSmiToPackedDouble', 1000, CreateSortFn([cmp_packed_smi_to_double]),
CreatePackedSmiArray, AssertPackedDoubleElements);
createSuite(
'HoleySmiToHoleyDouble', 1000, CreateSortFn([cmp_holey_smi_to_double]),
CreateHoleySmiArray, AssertHoleyDoubleElements);
createSuite(
'PackedDoubleToHoleyDouble', 1000, CreateSortFn([cmp_double_to_double]),
CreatePackedDoubleArray, AssertHoleyDoubleElements);
let cmp_packed_to_dict = CreateCompareFn(() => array_to_sort[%MaxSmi()] = 42);
let cmp_holey_to_dict = CreateCompareFn(() => array_to_sort[%MaxSmi()] = 42);
benchy('PackedElementToDictionary', CreateSortFn([cmp_packed_to_dict]),
CreatePackedObjectArray, AssertDictionaryElements);
benchy('HoleyElementToDictionary', CreateSortFn([cmp_holey_to_dict]),
CreateHoleyObjectArray, AssertDictionaryElements);
createSuite(
'PackedElementToDictionary', 1000, CreateSortFn([cmp_packed_to_dict]),
CreatePackedObjectArray, AssertDictionaryElements);
createSuite(
'HoleyElementToDictionary', 1000, CreateSortFn([cmp_holey_to_dict]),
CreateHoleyObjectArray, AssertDictionaryElements);
......@@ -7,15 +7,14 @@ load('sort-base.js');
// Each benchmark calls sort with multiple different comparison functions
// to create polyomorphic call sites. Most/all of the
// other sort benchmarks have monomorphic call sites.
let sortfn = CreateSortFn([cmp_smaller, cmp_greater]);
benchy('PackedSmi', sortfn, CreatePackedSmiArray);
benchy('PackedDouble', sortfn, CreatePackedDoubleArray);
benchy('PackedElement', sortfn, CreatePackedObjectArray);
createSuite('PackedSmi', 1000, sortfn, CreatePackedSmiArray);
createSuite('PackedDouble', 1000, sortfn, CreatePackedDoubleArray);
createSuite('PackedElement', 1000, sortfn, CreatePackedObjectArray);
benchy('HoleySmi', sortfn, CreateHoleySmiArray);
benchy('HoleyDouble', sortfn, CreateHoleyDoubleArray);
benchy('HoleyElement', sortfn, CreateHoleyObjectArray);
createSuite('HoleySmi', 1000, sortfn, CreateHoleySmiArray);
createSuite('HoleyDouble', 1000, sortfn, CreateHoleyDoubleArray);
createSuite('HoleyElement', 1000, sortfn, CreateHoleyObjectArray);
benchy('Dictionary', sortfn, CreateDictionaryArray);
createSuite('Dictionary', 1000, sortfn, CreateDictionaryArray);
......@@ -15,5 +15,5 @@ function SetupPreSortedReversed() {
array_to_sort.reverse();
}
benchy('PackedSmiPreSorted', Sort, SetupPreSorted);
benchy('PackedSmiPreSortedReversed', Sort, SetupPreSortedReversed);
createSuite('PackedSmiPreSorted', 1000, Sort, SetupPreSorted);
createSuite('PackedSmiPreSortedReversed', 1000, Sort, SetupPreSortedReversed);
......@@ -4,12 +4,12 @@
load('sort-base.js');
benchy('PackedSmi', Sort, CreatePackedSmiArray);
benchy('PackedDouble', Sort, CreatePackedDoubleArray);
benchy('PackedElement', Sort, CreatePackedObjectArray);
createSuite('PackedSmi', 1000, Sort, CreatePackedSmiArray);
createSuite('PackedDouble', 1000, Sort, CreatePackedDoubleArray);
createSuite('PackedElement', 1000, Sort, CreatePackedObjectArray);
benchy('HoleySmi', Sort, CreateHoleySmiArray);
benchy('HoleyDouble', Sort, CreateHoleyDoubleArray);
benchy('HoleyElement', Sort, CreateHoleyObjectArray);
createSuite('HoleySmi', 1000, Sort, CreateHoleySmiArray);
createSuite('HoleyDouble', 1000, Sort, CreateHoleyDoubleArray);
createSuite('HoleyElement', 1000, Sort, CreateHoleyObjectArray);
benchy('Dictionary', Sort, CreateDictionaryArray);
createSuite('Dictionary', 1000, Sort, CreateDictionaryArray);
......@@ -3,77 +3,70 @@
// found in the LICENSE file.
(function() {
function benchy(name, test, testSetup) {
new BenchmarkSuite(name, [10000], [
new Benchmark(name, false, false, 0, test, testSetup, TearDown)
]);
}
createSuite('Debugger.paused', 10000, DebuggerPaused, Setup, TearDown);
createSuite(
'Debugger.getPossibleBreakpoints', 10000, DebuggerGetPossibleBreakpoints,
SetupGetPossibleBreakpoints, TearDown);
createSuite(
'AsyncStacksInstrumentation', 10000, AsyncStacksInstrumentation,
SetupAsyncStacksInstrumentation, TearDown);
benchy('Debugger.paused', DebuggerPaused, Setup);
benchy('Debugger.getPossibleBreakpoints',
DebuggerGetPossibleBreakpoints,
SetupGetPossibleBreakpoints);
benchy('AsyncStacksInstrumentation',
AsyncStacksInstrumentation,
SetupAsyncStacksInstrumentation);
function Setup() {
SendMessage('Debugger.enable');
// Force lazy compilation of inspector related scripts.
SendMessage('Runtime.evaluate', {expression: ''});
}
function Setup() {
SendMessage('Debugger.enable');
// Force lazy compilation of inspector related scripts.
SendMessage('Runtime.evaluate', {expression: ''});
}
function TearDown() {
SendMessage('Debugger.disable');
}
function TearDown() {
SendMessage('Debugger.disable');
}
function DebuggerPaused() {
for (var i = 0; i < 10; ++i) {
debugger;
}
function DebuggerPaused() {
for (var i = 0; i < 10; ++i) {
debugger;
}
}
let scriptId;
function SetupGetPossibleBreakpoints() {
Setup();
let expression = '';
for (let i = 0; i < 20; ++i) {
expression += `function foo${i}(){
if (a) {
return true;
} else {
return false;
let scriptId;
function SetupGetPossibleBreakpoints() {
Setup();
let expression = '';
for (let i = 0; i < 20; ++i) {
expression += `function foo${i}(){
if (a) {
return true;
} else {
return false;
}
}\n`;
}
}\n`;
listener = function(msg) {
if (msg.method === 'Debugger.scriptParsed') {
scriptId = msg.params.scriptId;
listener = null;
}
listener = function(msg) {
if (msg.method === "Debugger.scriptParsed") {
scriptId = msg.params.scriptId;
listener = null;
}
}
SendMessage('Runtime.evaluate', {expression});
}
} SendMessage('Runtime.evaluate', {expression});
}
function DebuggerGetPossibleBreakpoints() {
SendMessage('Debugger.getPossibleBreakpoints', {
start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}
});
}
function DebuggerGetPossibleBreakpoints() {
SendMessage(
'Debugger.getPossibleBreakpoints',
{start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}});
}
function SetupAsyncStacksInstrumentation() {
Setup();
SendMessage('Debugger.setAsyncCallStackDepth', {maxDepth: 1024});
}
function SetupAsyncStacksInstrumentation() {
Setup();
SendMessage('Debugger.setAsyncCallStackDepth', {maxDepth: 1024});
}
function AsyncStacksInstrumentation() {
var p = Promise.resolve();
var nopCallback = () => undefined;
var done = false;
for (let i = 0; i < 1000; ++i) {
p = p.then(nopCallback);
}
p = p.then(() => done = true);
while (!done) %RunMicrotasks();
function AsyncStacksInstrumentation() {
var p = Promise.resolve();
var nopCallback = () => undefined;
var done = false;
for (let i = 0; i < 1000; ++i) {
p = p.then(nopCallback);
}
p = p.then(() => done = true);
while (!done) %RunMicrotasks();
}
})();
......@@ -18,7 +18,6 @@ function PrintError(name, error) {
success = false;
}
BenchmarkSuite.config.doWarmup = undefined;
BenchmarkSuite.config.doDeterministic = undefined;
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function benchy(fn, name) {
new BenchmarkSuite(name, [1], [
function createSuiteWithWarmup( name, count, fn) {
new BenchmarkSuite(name, [count], [
new Benchmark(name, true, false, 0, fn),
]);
}
......@@ -41,7 +41,7 @@ function endsIndex(string) {
return string[string.length - 1] === first;
}
benchy(() => helper(startsWith), 'startsWith');
benchy(() => helper(startsIndex), 'startsIndex');
benchy(() => helper(endsWith), 'endsWith');
benchy(() => helper(endsIndex), 'endsIndex');
createSuiteWithWarmup('startsWith', 1, () => helper(startsWith));
createSuiteWithWarmup('startsIndex', 1, () => helper(startsIndex));
createSuiteWithWarmup('endsWith', 1, () => helper(endsWith));
createSuiteWithWarmup('endsIndex', 1, () => helper(endsIndex));
......@@ -2,12 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function benchy(f, name) {
new BenchmarkSuite(name, [1], [
new Benchmark(name, true, false, 0, f),
]);
}
const input = 'äϠ�𝌆 Lorem ipsum test test';
function helper(fn) {
......@@ -42,9 +36,9 @@ function stringIndex(str, i) {
return str[i] === 't';
}
benchy(() => helper(charCodeAt), "charCodeAt_const");
benchy(() => helper(charCodeAtBoth), "charCodeAt_both");
benchy(() => helper(charAt), "charAt_const");
benchy(() => helper(charAtNever), "charAt_never");
benchy(() => helper(charAtBoth), "charAt_both");
benchy(() => helper(stringIndex), "stringIndex_const");
createSuiteWithWarmup('charCodeAt_const', 1, () => helper(charCodeAt));
createSuiteWithWarmup('charCodeAt_both', 1, () => helper(charCodeAtBoth));
createSuiteWithWarmup('charAt_const', 1, () => helper(charAt));
createSuiteWithWarmup('charAt_never', 1, () => helper(charAtNever));
createSuiteWithWarmup('charAt_both', 1, () => helper(charAtBoth));
createSuiteWithWarmup('stringIndex_const', 1, () => helper(stringIndex));
......@@ -2,14 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function benchy (f, name) {
new BenchmarkSuite(name, [5], [
new Benchmark(name, true, false, 0,
f),
]);
}
const subjects = ['abcde', '123456', 'aqwsde', "nbvveqxu", "f03ks-120-3;jfkm;ajp3f", "sd-93u498thikefnow8y3-0rh1nalksfnwo8y3t19-3r8hoiefnw"];
const subjects = [
'abcde', '123456', 'aqwsde', 'nbvveqxu', 'f03ks-120-3;jfkm;ajp3f',
'sd-93u498thikefnow8y3-0rh1nalksfnwo8y3t19-3r8hoiefnw'
];
// Drop first element.
......@@ -23,7 +19,7 @@ function StringDropFirstSlice() {
return sum;
}
benchy(StringDropFirstSlice, "StringDropFirstSlice");
createSuiteWithWarmup('StringDropFirstSlice', 5, StringDropFirstSlice);
function StringDropFirstSubstr() {
var sum = "";
......@@ -35,7 +31,7 @@ function StringDropFirstSubstr() {
return sum;
}
benchy(StringDropFirstSubstr, "StringDropFirstSubstr");
createSuiteWithWarmup('StringDropFirstSubstr', 5, StringDropFirstSubstr);
function StringDropFirstSubstring() {
var sum = "";
......@@ -47,8 +43,7 @@ function StringDropFirstSubstring() {
return sum;
}
benchy(StringDropFirstSubstring, "StringDropFirstSubstring");
createSuiteWithWarmup('StringDropFirstSubstring', 5, StringDropFirstSubstring);
// Take first element.
......@@ -62,7 +57,7 @@ function StringTakeFirstSlice() {
return sum;
}
benchy(StringTakeFirstSlice, "StringTakeFirstSlice");
createSuiteWithWarmup('StringTakeFirstSlice', 5, StringTakeFirstSlice);
function StringTakeFirstSubstr() {
var sum = "";
......@@ -74,7 +69,7 @@ function StringTakeFirstSubstr() {
return sum;
}
benchy(StringTakeFirstSubstr, "StringTakeFirstSubstr");
createSuiteWithWarmup('StringTakeFirstSubstr', 5, StringTakeFirstSubstr);
function StringTakeFirstSubstring() {
var sum = "";
......@@ -86,8 +81,7 @@ function StringTakeFirstSubstring() {
return sum;
}
benchy(StringTakeFirstSubstring, "StringTakeFirstSubstring");
createSuiteWithWarmup('StringTakeFirstSubstring', 5, StringTakeFirstSubstring);
// Drop last element.
......@@ -101,7 +95,7 @@ function StringDropLastSlice() {
return sum;
}
benchy(StringDropLastSlice, "StringDropLastSlice");
createSuiteWithWarmup('StringDropLastSlice', 5, StringDropLastSlice);
function StringDropLastSubstr() {
var sum = "";
......@@ -113,7 +107,7 @@ function StringDropLastSubstr() {
return sum;
}
benchy(StringDropLastSubstr, "StringDropLastSubstr");
createSuiteWithWarmup('StringDropLastSubstr', 5, StringDropLastSubstr);
function StringDropLastSubstring() {
var sum = "";
......@@ -125,8 +119,7 @@ function StringDropLastSubstring() {
return sum;
}
benchy(StringDropLastSubstring, "StringDropLastSubstring");
createSuiteWithWarmup('StringDropLastSubstring', 5, StringDropLastSubstring);
// Take last element.
......@@ -140,7 +133,7 @@ function StringTakeLastSlice() {
return sum;
}
benchy(StringTakeLastSlice, "StringTakeLastSlice");
createSuiteWithWarmup('StringTakeLastSlice', 5, StringTakeLastSlice);
function StringTakeLastSubstr() {
var sum = "";
......@@ -152,7 +145,7 @@ function StringTakeLastSubstr() {
return sum;
}
benchy(StringTakeLastSubstr, "StringTakeLastSubstr");
createSuiteWithWarmup('StringTakeLastSubstr', 5, StringTakeLastSubstr);
function StringTakeLastSubstring() {
var sum = "";
......@@ -164,8 +157,7 @@ function StringTakeLastSubstring() {
return sum;
}
benchy(StringTakeLastSubstring, "StringTakeLastSubstring");
createSuiteWithWarmup('StringTakeLastSubstring', 5, StringTakeLastSubstring);
// Drop first and last.
......@@ -179,7 +171,7 @@ function StringDropFirstSlice() {
return sum;
}
benchy(StringDropFirstSlice, "StringDropFirstSlice");
createSuiteWithWarmup('StringDropFirstSlice', 5, StringDropFirstSlice);
function StringDropFirstSubstr() {
var sum = "";
......@@ -191,7 +183,7 @@ function StringDropFirstSubstr() {
return sum;
}
benchy(StringDropFirstSubstr, "StringDropFirstSubstr");
createSuiteWithWarmup('StringDropFirstSubstr', 5, StringDropFirstSubstr);
function StringDropFirstSubstring() {
var sum = "";
......@@ -203,4 +195,4 @@ function StringDropFirstSubstring() {
return sum;
}
benchy(StringDropFirstSubstring, "StringDropFirstSubstring");
createSuiteWithWarmup('StringDropFirstSubstring', 5, StringDropFirstSubstring);
......@@ -54,7 +54,6 @@ BenchmarkResult.prototype.valueOf = function() {
return this.time;
}
// Suites of benchmarks consist of a name and the set of benchmarks in
// addition to the reference timing that the final score will be based
// on. This way, all scores are relative to a reference run and higher
......@@ -66,6 +65,16 @@ function BenchmarkSuite(name, reference, benchmarks) {
BenchmarkSuite.suites.push(this);
}
function createSuite(name, count, test, testSetup, tearDown) {
return new BenchmarkSuite(name, [count], [
new Benchmark(name, false, false, 0, test, testSetup, tearDown]);
}
function createSuiteWithWarmup(name, count, testSetup, tearDown) {
new BenchmarkSuite(name, [count], [
new Benchmark(name, true, false, 0, fn),
]);
}
// Keep track of all declared benchmark suites.
BenchmarkSuite.suites = [];
......
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