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