[class] refactor ClassFields benchmarks and copy them into JSTests3
This patch refactors the ClassFields benchmarks and makes the results detection work properly. Previously the errors weren't caught since the ClassFields benchmarks don't get run in the perf_integration step in the CI. - Instead of putting different configs (single/multiple fields, type of fields, etc.)in the JSON configuration, we now group the related benchmarks into the same script and run the different configurations in the scripts directly. Only the optimization status is now controlled in JSON. All the class fields definition benchmarks are merged into initialize-class.js. - Update the number of local iterations of evaluate-class.js to 100 (similar to most of other benchmarks) to keep the time spent on this benchmark similar to that of other benchmarks. In addition, copy the configs to JSTests3 so that the benchmarks gets run by the perf_integration step and we can see the graphs on http://chromeperf.appspot.com/report. These can be removed when the ClassFields benchmark results are generated there too. Bug: v8:10793, v8:9888 Change-Id: I4e677bdc7b582650f39cf6e9ec02775c57fd04ab Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3226550 Commit-Queue: Joyee Cheung <joyee@igalia.com> Reviewed-by: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/main@{#77640}
This commit is contained in:
parent
48b2b89176
commit
d28bfcd570
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"owners": ["caitp@igalia.com", "joyee@igalia.com"],
|
"owners": ["caitp@igalia.com", "joyee@igalia.com"],
|
||||||
"name": "ClassFields",
|
"name": "ClassFields",
|
||||||
"path": ["ClassFields"],
|
|
||||||
"run_count": 3,
|
"run_count": 3,
|
||||||
"run_count_arm": 1,
|
"run_count_arm": 1,
|
||||||
"run_count_arm64": 1,
|
"run_count_arm64": 1,
|
||||||
@ -10,157 +9,70 @@
|
|||||||
"units": "score",
|
"units": "score",
|
||||||
"total": true,
|
"total": true,
|
||||||
"resources": ["base.js"],
|
"resources": ["base.js"],
|
||||||
|
"flags": ["--allow-natives-syntax"],
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{
|
||||||
"name": "evaluate-class",
|
"name": "EvaluateClassOpt",
|
||||||
"flags": ["--allow-natives-syntax"],
|
"path": ["ClassFields"],
|
||||||
"resources": [ "evaluate-class.js", "classes.js" ],
|
"test_flags": [ "evaluate-class", "opt" ],
|
||||||
|
"main": "run.js",
|
||||||
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
||||||
|
"resources": ["classes.js", "evaluate-class.js"],
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{"name": "EvaluateSinglePublicFieldClassOpt"},
|
||||||
"name": "evaluate-class-public-field-single-opt",
|
{"name": "EvaluateMultiPublicFieldClassOpt"},
|
||||||
"main": "run.js",
|
{"name": "EvaluateSinglePrivateFieldClassOpt"},
|
||||||
"test_flags": [ "evaluate-class", "public-field-single", "opt" ]
|
{"name": "EvaluateMultiPrivateFieldClassOpt"},
|
||||||
},
|
{"name": "EvaluateSingleComputedFieldClassOpt"},
|
||||||
{
|
{"name": "EvaluateMultiComputedFieldClassOpt"}
|
||||||
"name": "evaluate-class-public-field-single-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "public-field-single", "noopt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "evaluate-class-private-field-single-opt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "private-field-single", "opt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "evaluate-class-private-field-single-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "private-field-single", "noopt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "evaluate-class-public-field-multiple-opt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "public-field-multiple", "opt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "evaluate-class-public-field-multiple-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "public-field-multiple", "noopt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "evaluate-class-private-field-multiple-opt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "private-field-multiple", "opt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "evaluate-class-private-field-multiple-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "private-field-multiple", "noopt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "evaluate-class-computed-field-single-opt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "computed-field-single", "opt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "evaluate-class-computed-field-single-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "computed-field-single", "noopt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "evaluate-class-computed-field-multiple-opt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "computed-field-multiple", "opt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "evaluate-class-computed-field-multiple-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "evaluate-class", "computed-field-multiple", "noopt" ]
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "define-public-field",
|
"name": "EvaluateClassNoOpt",
|
||||||
"flags": ["--allow-natives-syntax"],
|
"path": ["ClassFields"],
|
||||||
"resources": [ "define-public-field.js", "classes.js" ],
|
"test_flags": [ "evaluate-class", "noopt" ],
|
||||||
|
"main": "run.js",
|
||||||
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
||||||
|
"resources": ["classes.js", "evaluate-class.js"],
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{"name": "EvaluateSinglePublicFieldClassNoOpt"},
|
||||||
"name": "define-public-field-single-opt",
|
{"name": "EvaluateMultiPublicFieldClassNoOpt"},
|
||||||
"main": "run.js",
|
{"name": "EvaluateSinglePrivateFieldClassNoOpt"},
|
||||||
"test_flags": [ "define-public-field", "single", "opt" ]
|
{"name": "EvaluateMultiPrivateFieldClassNoOpt"},
|
||||||
},
|
{"name": "EvaluateSingleComputedFieldClassNoOpt"},
|
||||||
{
|
{"name": "EvaluateMultiComputedFieldClassNoOpt"}
|
||||||
"name": "define-public-field-single-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "define-public-field", "single", "noopt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "define-public-field-multiple-opt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "define-public-field", "multiple", "opt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "define-public-field-multiple-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "define-public-field", "multiple", "noopt" ]
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "define-private-field",
|
"name": "InitializeClassOpt",
|
||||||
"resources": [ "define-private-field.js", "classes.js" ],
|
"path": ["ClassFields"],
|
||||||
"flags": ["--allow-natives-syntax"],
|
"test_flags": [ "initialize-instance", "opt" ],
|
||||||
|
"main": "run.js",
|
||||||
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
||||||
|
"resources": ["classes.js", "initialize-instance.js"],
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{"name": "InitializeSinglePublicFieldClassOpt"},
|
||||||
"name": "define-private-field-single-opt",
|
{"name": "InitializeMultiPublicFieldClassOpt"},
|
||||||
"main": "run.js",
|
{"name": "InitializeSinglePrivateFieldClassOpt"},
|
||||||
"test_flags": [ "define-private-field", "single", "opt" ]
|
{"name": "InitializeMultiPrivateFieldClassOpt"},
|
||||||
},
|
{"name": "InitializeSingleComputedFieldClassOpt"},
|
||||||
{
|
{"name": "InitializeMultiComputedFieldClassOpt"}
|
||||||
"name": "define-private-field-single-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "define-private-field", "single", "noopt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "define-private-field-multiple-opt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "define-private-field", "multiple", "opt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "define-private-field-multiple-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "define-private-field", "multiple", "noopt" ]
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "define-computed-field",
|
"name": "InitializeClassNoOpt",
|
||||||
"resources": [ "define-computed-field.js", "classes.js" ],
|
"path": ["ClassFields"],
|
||||||
"flags": ["--allow-natives-syntax"],
|
"test_flags": [ "initialize-instance", "noopt" ],
|
||||||
|
"main": "run.js",
|
||||||
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
||||||
|
"resources": ["classes.js", "initialize-instance.js"],
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{"name": "InitializeSinglePublicFieldClassNoOpt"},
|
||||||
"name": "define-computed-field-single-opt",
|
{"name": "InitializeMultiPublicFieldClassNoOpt"},
|
||||||
"main": "run.js",
|
{"name": "InitializeSinglePrivateFieldClassNoOpt"},
|
||||||
"test_flags": [ "define-computed-field", "single", "opt" ]
|
{"name": "InitializeMultiPrivateFieldClassNoOpt"},
|
||||||
},
|
{"name": "InitializeSingleComputedFieldClassNoOpt"},
|
||||||
{
|
{"name": "InitializeMultiComputedFieldClassNoOpt"}
|
||||||
"name": "define-computed-field-single-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "define-computed-field", "single", "noopt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "define-computed-field-multiple-opt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "define-computed-field", "multiple", "opt" ]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "define-computed-field-multiple-noopt",
|
|
||||||
"main": "run.js",
|
|
||||||
"test_flags": [ "define-computed-field", "multiple", "noopt" ]
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
// Copyright 2021 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.
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
d8.file.execute('classes.js');
|
|
||||||
|
|
||||||
const BENCHMARK_NAME = arguments[0];
|
|
||||||
const TEST_TYPE = arguments[1];
|
|
||||||
const optimize_param = arguments[2];
|
|
||||||
let optimize;
|
|
||||||
if (optimize_param == "opt") {
|
|
||||||
optimize = true;
|
|
||||||
} else if (optimize_param == "noopt"){
|
|
||||||
optimize = false;
|
|
||||||
} else {
|
|
||||||
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
let klass;
|
|
||||||
let array;
|
|
||||||
|
|
||||||
switch (TEST_TYPE) {
|
|
||||||
case "single":
|
|
||||||
klass = EvaluateSingleComputedFieldClass();
|
|
||||||
break;
|
|
||||||
case "multiple":
|
|
||||||
klass = EvaluateMultiComputedFieldClass();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optimize) {
|
|
||||||
%PrepareFunctionForOptimization(klass);
|
|
||||||
} else {
|
|
||||||
%NeverOptimizeFunction(klass);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setUp() {
|
|
||||||
array = [new klass(), new klass()];
|
|
||||||
// Populate the array first to reduce the impact of
|
|
||||||
// array allocations.
|
|
||||||
for (let i = 0; i < LOCAL_ITERATIONS - 2; ++i) {
|
|
||||||
array.push(array[0]);
|
|
||||||
}
|
|
||||||
if (optimize) {
|
|
||||||
%OptimizeFunctionOnNextCall(klass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function runBenchmark() {
|
|
||||||
for (let i = 0; i < LOCAL_ITERATIONS; ++i) {
|
|
||||||
array[i] = new klass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function tearDown() {
|
|
||||||
if (array.length < 3) {
|
|
||||||
throw new Error(`Check failed, array length ${array.length}`);
|
|
||||||
}
|
|
||||||
for (const instance of array) {
|
|
||||||
if (!instance.check())
|
|
||||||
throw new Error(`instance.check() failed`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const DETERMINISTIC_RUNS = 1;
|
|
||||||
const LOCAL_ITERATIONS = 10000;
|
|
||||||
new BenchmarkSuite(`${BENCHMARK_NAME}`, [1000], [
|
|
||||||
new Benchmark(
|
|
||||||
`${BENCHMARK_NAME}-${TEST_TYPE}-${optimize_param}`,
|
|
||||||
false, false, DETERMINISTIC_RUNS, runBenchmark, setUp, tearDown)
|
|
||||||
]);
|
|
@ -1,74 +0,0 @@
|
|||||||
// Copyright 2021 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.
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
d8.file.execute('classes.js');
|
|
||||||
|
|
||||||
const BENCHMARK_NAME = arguments[0];
|
|
||||||
const TEST_TYPE = arguments[1];
|
|
||||||
const optimize_param = arguments[2];
|
|
||||||
let optimize;
|
|
||||||
if (optimize_param == "opt") {
|
|
||||||
optimize = true;
|
|
||||||
} else if (optimize_param == "noopt"){
|
|
||||||
optimize = false;
|
|
||||||
} else {
|
|
||||||
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
let klass;
|
|
||||||
let array;
|
|
||||||
|
|
||||||
switch (TEST_TYPE) {
|
|
||||||
case "single":
|
|
||||||
klass = EvaluateSinglePrivateFieldClass();
|
|
||||||
break;
|
|
||||||
case "multiple":
|
|
||||||
klass = EvaluateMultiPrivateFieldClass();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optimize) {
|
|
||||||
%PrepareFunctionForOptimization(klass);
|
|
||||||
} else {
|
|
||||||
%NeverOptimizeFunction(klass);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setUp() {
|
|
||||||
array = [new klass(), new klass()];
|
|
||||||
// Populate the array first to reduce the impact of
|
|
||||||
// array allocations.
|
|
||||||
for (let i = 0; i < LOCAL_ITERATIONS - 2; ++i) {
|
|
||||||
array.push(array[0]);
|
|
||||||
}
|
|
||||||
if (optimize) {
|
|
||||||
%OptimizeFunctionOnNextCall(klass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function runBenchmark() {
|
|
||||||
for (let i = 0; i < LOCAL_ITERATIONS; ++i) {
|
|
||||||
array[i] = new klass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function tearDown() {
|
|
||||||
if (array.length < 3) {
|
|
||||||
throw new Error(`Check failed, array length ${array.length}`);
|
|
||||||
}
|
|
||||||
for (const instance of array) {
|
|
||||||
if (!instance.check())
|
|
||||||
throw new Error(`instance.check() failed`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const DETERMINISTIC_RUNS = 1;
|
|
||||||
const LOCAL_ITERATIONS = 10000;
|
|
||||||
new BenchmarkSuite(`${BENCHMARK_NAME}`, [1000], [
|
|
||||||
new Benchmark(
|
|
||||||
`${BENCHMARK_NAME}-${TEST_TYPE}-${optimize_param}`,
|
|
||||||
false, false, DETERMINISTIC_RUNS, runBenchmark, setUp, tearDown)
|
|
||||||
]);
|
|
@ -1,75 +0,0 @@
|
|||||||
// Copyright 2021 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.
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
d8.file.execute('classes.js');
|
|
||||||
|
|
||||||
const BENCHMARK_NAME = arguments[0];
|
|
||||||
const TEST_TYPE = arguments[1];
|
|
||||||
const optimize_param = arguments[2];
|
|
||||||
let optimize;
|
|
||||||
if (optimize_param == "opt") {
|
|
||||||
optimize = true;
|
|
||||||
} else if (optimize_param == "noopt"){
|
|
||||||
optimize = false;
|
|
||||||
} else {
|
|
||||||
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
let klass;
|
|
||||||
let array;
|
|
||||||
|
|
||||||
switch (TEST_TYPE) {
|
|
||||||
case "single":
|
|
||||||
klass = EvaluateSinglePublicFieldClass();
|
|
||||||
break;
|
|
||||||
case "multiple":
|
|
||||||
klass = EvaluateMultiPublicFieldClass();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optimize) {
|
|
||||||
%PrepareFunctionForOptimization(klass);
|
|
||||||
} else {
|
|
||||||
%NeverOptimizeFunction(klass);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setUp() {
|
|
||||||
array = [new klass(), new klass()];
|
|
||||||
// Populate the array first to reduce the impact of
|
|
||||||
// array allocations.
|
|
||||||
for (let i = 0; i < LOCAL_ITERATIONS - 2; ++i) {
|
|
||||||
array.push(array[0]);
|
|
||||||
}
|
|
||||||
if (optimize) {
|
|
||||||
%OptimizeFunctionOnNextCall(klass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function runBenchmark() {
|
|
||||||
for (let i = 0; i < LOCAL_ITERATIONS; ++i) {
|
|
||||||
array[i] = new klass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function tearDown() {
|
|
||||||
if (array.length < 3) {
|
|
||||||
throw new Error(`Check failed, array length ${array.length}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const instance of array) {
|
|
||||||
if (!instance.check())
|
|
||||||
throw new Error(`instance.check() failed`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const DETERMINISTIC_RUNS = 1;
|
|
||||||
const LOCAL_ITERATIONS = 10000;
|
|
||||||
new BenchmarkSuite(`${BENCHMARK_NAME}`, [1000], [
|
|
||||||
new Benchmark(
|
|
||||||
`${BENCHMARK_NAME}-${TEST_TYPE}-${optimize_param}`,
|
|
||||||
false, false, DETERMINISTIC_RUNS, runBenchmark, setUp, tearDown)
|
|
||||||
]);
|
|
@ -5,85 +5,95 @@
|
|||||||
|
|
||||||
d8.file.execute('classes.js');
|
d8.file.execute('classes.js');
|
||||||
|
|
||||||
const BENCHMARK_NAME = arguments[0];
|
function CreateBenchmark(name, optimize) {
|
||||||
const TEST_TYPE = arguments[1];
|
let factory;
|
||||||
const optimize_param = arguments[2];
|
let array;
|
||||||
let optimize;
|
|
||||||
if (optimize_param == "opt") {
|
switch (name) {
|
||||||
optimize = true;
|
case "EvaluateSinglePublicFieldClass":
|
||||||
} else if (optimize_param == "noopt"){
|
factory = EvaluateSinglePublicFieldClass;
|
||||||
optimize = false;
|
break;
|
||||||
} else {
|
case "EvaluateMultiPublicFieldClass":
|
||||||
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
factory = EvaluateMultiPublicFieldClass;
|
||||||
|
break;
|
||||||
|
case "EvaluateSinglePrivateFieldClass":
|
||||||
|
factory = EvaluateSinglePrivateFieldClass;
|
||||||
|
break;
|
||||||
|
case "EvaluateMultiPrivateFieldClass":
|
||||||
|
factory = EvaluateMultiPrivateFieldClass;
|
||||||
|
break;
|
||||||
|
case "EvaluateSingleComputedFieldClass":
|
||||||
|
factory = EvaluateSingleComputedFieldClass;
|
||||||
|
break;
|
||||||
|
case "EvaluateMultiComputedFieldClass":
|
||||||
|
factory = EvaluateMultiComputedFieldClass;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optimize) {
|
||||||
|
%PrepareFunctionForOptimization(factory);
|
||||||
|
} else {
|
||||||
|
%NeverOptimizeFunction(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
array = [factory(), factory()];
|
||||||
|
// Populate the array first to reduce the impact of
|
||||||
|
// array allocations.
|
||||||
|
for (let i = 0; i < LOCAL_ITERATIONS - 2; ++i) {
|
||||||
|
array.push(array[0]);
|
||||||
|
}
|
||||||
|
if (optimize) {
|
||||||
|
%OptimizeFunctionOnNextCall(factory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function runBenchmark() {
|
||||||
|
for (let i = 0; i < LOCAL_ITERATIONS; ++i) {
|
||||||
|
array[i] = factory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function tearDown() {
|
||||||
|
if (array.length < 3) {
|
||||||
|
throw new Error(`Check failed, array length ${array.length}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const klass of array) {
|
||||||
|
const instance = new klass();
|
||||||
|
if (!instance.check())
|
||||||
|
throw new Error(`instance.check() failed`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const DETERMINISTIC_RUNS = 1;
|
||||||
|
const LOCAL_ITERATIONS = 100;
|
||||||
|
|
||||||
|
const benchName = `${name}${optimize ? "Opt" : "NoOpt"}`
|
||||||
|
new BenchmarkSuite(benchName, [1000], [
|
||||||
|
new Benchmark(
|
||||||
|
benchName,
|
||||||
|
false, false, DETERMINISTIC_RUNS, runBenchmark, setUp, tearDown)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let factory;
|
let optimize;
|
||||||
let array;
|
switch (arguments[1]) {
|
||||||
|
case 'opt':
|
||||||
switch (TEST_TYPE) {
|
optimize = true;
|
||||||
case "public-field-single":
|
|
||||||
factory = EvaluateSinglePublicFieldClass;
|
|
||||||
break;
|
break;
|
||||||
case "public-field-multiple":
|
case 'noopt':
|
||||||
factory = EvaluateMultiPublicFieldClass;
|
optimize = false;
|
||||||
break;
|
break;
|
||||||
case "private-field-single":
|
|
||||||
factory = EvaluateSinglePrivateFieldClass;
|
|
||||||
break;
|
|
||||||
case "private-field-multiple":
|
|
||||||
factory = EvaluateMultiPrivateFieldClass;
|
|
||||||
break;
|
|
||||||
case "computed-field-single":
|
|
||||||
factory = EvaluateSingleComputedFieldClass;
|
|
||||||
break;
|
|
||||||
case "computed-field-multiple":
|
|
||||||
factory = EvaluateMultiComputedFieldClass;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optimize) {
|
CreateBenchmark("EvaluateSinglePublicFieldClass", optimize);
|
||||||
%PrepareFunctionForOptimization(factory);
|
CreateBenchmark("EvaluateMultiPublicFieldClass", optimize);
|
||||||
} else {
|
CreateBenchmark("EvaluateSinglePrivateFieldClass", optimize);
|
||||||
%NeverOptimizeFunction(factory);
|
CreateBenchmark("EvaluateMultiPrivateFieldClass", optimize);
|
||||||
}
|
CreateBenchmark("EvaluateSingleComputedFieldClass", optimize);
|
||||||
|
CreateBenchmark("EvaluateMultiComputedFieldClass", optimize);
|
||||||
function setUp() {
|
|
||||||
array = [factory(), factory()];
|
|
||||||
// Populate the array first to reduce the impact of
|
|
||||||
// array allocations.
|
|
||||||
for (let i = 0; i < LOCAL_ITERATIONS - 2; ++i) {
|
|
||||||
array.push(array[0]);
|
|
||||||
}
|
|
||||||
if (optimize) {
|
|
||||||
%OptimizeFunctionOnNextCall(factory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function runBenchmark() {
|
|
||||||
for (let i = 0; i < LOCAL_ITERATIONS; ++i) {
|
|
||||||
array[i] = factory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function tearDown() {
|
|
||||||
if (array.length < 3) {
|
|
||||||
throw new Error(`Check failed, array length ${array.length}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const klass of array) {
|
|
||||||
const instance = new klass();
|
|
||||||
if (!instance.check())
|
|
||||||
throw new Error(`instance.check() failed`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const DETERMINISTIC_RUNS = 1;
|
|
||||||
const LOCAL_ITERATIONS = 10000;
|
|
||||||
new BenchmarkSuite(`${BENCHMARK_NAME}`, [1000], [
|
|
||||||
new Benchmark(
|
|
||||||
`${BENCHMARK_NAME}-${TEST_TYPE}-${optimize_param}`,
|
|
||||||
false, false, DETERMINISTIC_RUNS, runBenchmark, setUp, tearDown)
|
|
||||||
]);
|
|
||||||
|
98
test/js-perf-test/ClassFields/initialize-instance.js
Normal file
98
test/js-perf-test/ClassFields/initialize-instance.js
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
// Copyright 2021 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.
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
d8.file.execute('classes.js');
|
||||||
|
|
||||||
|
function CreateBenchmark(name, optimize) {
|
||||||
|
let klass;
|
||||||
|
let array;
|
||||||
|
|
||||||
|
switch (name) {
|
||||||
|
case "InitializeSinglePublicFieldClass":
|
||||||
|
klass = EvaluateSinglePublicFieldClass();
|
||||||
|
break;
|
||||||
|
case "InitializeMultiPublicFieldClass":
|
||||||
|
klass = EvaluateMultiPublicFieldClass();
|
||||||
|
break;
|
||||||
|
case "InitializeSinglePrivateFieldClass":
|
||||||
|
klass = EvaluateSinglePrivateFieldClass();
|
||||||
|
break;
|
||||||
|
case "InitializeMultiPrivateFieldClass":
|
||||||
|
klass = EvaluateMultiPrivateFieldClass();
|
||||||
|
break;
|
||||||
|
case "InitializeSingleComputedFieldClass":
|
||||||
|
klass = EvaluateSingleComputedFieldClass();
|
||||||
|
break;
|
||||||
|
case "InitializeMultiComputedFieldClass":
|
||||||
|
klass = EvaluateMultiComputedFieldClass();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optimize) {
|
||||||
|
%PrepareFunctionForOptimization(klass);
|
||||||
|
} else {
|
||||||
|
%NeverOptimizeFunction(klass);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
array = [new klass(), new klass()];
|
||||||
|
// Populate the array first to reduce the impact of
|
||||||
|
// array allocations.
|
||||||
|
for (let i = 0; i < LOCAL_ITERATIONS - 2; ++i) {
|
||||||
|
array.push(array[0]);
|
||||||
|
}
|
||||||
|
if (optimize) {
|
||||||
|
%OptimizeFunctionOnNextCall(klass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function runBenchmark() {
|
||||||
|
for (let i = 0; i < LOCAL_ITERATIONS; ++i) {
|
||||||
|
array[i] = new klass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function tearDown() {
|
||||||
|
if (array.length < 3) {
|
||||||
|
throw new Error(`Check failed, array length ${array.length}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const instance of array) {
|
||||||
|
if (!instance.check())
|
||||||
|
throw new Error(`instance.check() failed`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const DETERMINISTIC_RUNS = 1;
|
||||||
|
const LOCAL_ITERATIONS = 10000;
|
||||||
|
|
||||||
|
const benchName = `${name}${optimize ? "Opt" : "NoOpt"}`
|
||||||
|
new BenchmarkSuite(benchName, [1000], [
|
||||||
|
new Benchmark(
|
||||||
|
benchName,
|
||||||
|
false, false, DETERMINISTIC_RUNS, runBenchmark, setUp, tearDown)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let optimize;
|
||||||
|
switch (arguments[1]) {
|
||||||
|
case 'opt':
|
||||||
|
optimize = true;
|
||||||
|
break;
|
||||||
|
case 'noopt':
|
||||||
|
optimize = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error("Unknown optimization configuration " + arguments.join(' '));
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateBenchmark("InitializeSinglePublicFieldClass", optimize);
|
||||||
|
CreateBenchmark("InitializeMultiPublicFieldClass", optimize);
|
||||||
|
CreateBenchmark("InitializeSinglePrivateFieldClass", optimize);
|
||||||
|
CreateBenchmark("InitializeMultiPrivateFieldClass", optimize);
|
||||||
|
CreateBenchmark("InitializeSingleComputedFieldClass", optimize);
|
||||||
|
CreateBenchmark("InitializeMultiComputedFieldClass", optimize);
|
@ -8,7 +8,7 @@ load(arguments[0] + '.js');
|
|||||||
var success = true;
|
var success = true;
|
||||||
|
|
||||||
function PrintResult(name, result, mean) {
|
function PrintResult(name, result, mean) {
|
||||||
print(`${name}-ClassFields(Score): ${result} (mean: ${mean})`);
|
print(`${name}-ClassFields(Score): ${result}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,70 @@
|
|||||||
"total": true,
|
"total": true,
|
||||||
"resources": ["base.js"],
|
"resources": ["base.js"],
|
||||||
"tests": [
|
"tests": [
|
||||||
|
{
|
||||||
|
"name": "ClassFields",
|
||||||
|
"path": ["ClassFields"],
|
||||||
|
"flags": ["--allow-natives-syntax"],
|
||||||
|
"resources": [ "evaluate-class.js", "classes.js" ],
|
||||||
|
"tests": [
|
||||||
|
{
|
||||||
|
"name": "EvaluateClassOpt",
|
||||||
|
"test_flags": [ "evaluate-class", "opt" ],
|
||||||
|
"main": "run.js",
|
||||||
|
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
||||||
|
"tests": [
|
||||||
|
{"name": "EvaluateSinglePublicFieldClassOpt"},
|
||||||
|
{"name": "EvaluateMultiPublicFieldClassOpt"},
|
||||||
|
{"name": "EvaluateSinglePrivateFieldClassOpt"},
|
||||||
|
{"name": "EvaluateMultiPrivateFieldClassOpt"},
|
||||||
|
{"name": "EvaluateSingleComputedFieldClassOpt"},
|
||||||
|
{"name": "EvaluateMultiComputedFieldClassOpt"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EvaluateClassNoOpt",
|
||||||
|
"test_flags": [ "evaluate-class", "noopt" ],
|
||||||
|
"main": "run.js",
|
||||||
|
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
||||||
|
"tests": [
|
||||||
|
{"name": "EvaluateSinglePublicFieldClassNoOpt"},
|
||||||
|
{"name": "EvaluateMultiPublicFieldClassNoOpt"},
|
||||||
|
{"name": "EvaluateSinglePrivateFieldClassNoOpt"},
|
||||||
|
{"name": "EvaluateMultiPrivateFieldClassNoOpt"},
|
||||||
|
{"name": "EvaluateSingleComputedFieldClassNoOpt"},
|
||||||
|
{"name": "EvaluateMultiComputedFieldClassNoOpt"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "InitializeClassOpt",
|
||||||
|
"test_flags": [ "initialize-instance", "opt" ],
|
||||||
|
"main": "run.js",
|
||||||
|
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
||||||
|
"tests": [
|
||||||
|
{"name": "InitializeSinglePublicFieldClassOpt"},
|
||||||
|
{"name": "InitializeMultiPublicFieldClassOpt"},
|
||||||
|
{"name": "InitializeSinglePrivateFieldClassOpt"},
|
||||||
|
{"name": "InitializeMultiPrivateFieldClassOpt"},
|
||||||
|
{"name": "InitializeSingleComputedFieldClassOpt"},
|
||||||
|
{"name": "InitializeMultiComputedFieldClassOpt"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "InitializeClassNoOpt",
|
||||||
|
"test_flags": [ "initialize-instance", "noopt" ],
|
||||||
|
"main": "run.js",
|
||||||
|
"results_regexp": "^%s\\-ClassFields\\(Score\\): (.+)$",
|
||||||
|
"tests": [
|
||||||
|
{"name": "InitializeSinglePublicFieldClassNoOpt"},
|
||||||
|
{"name": "InitializeMultiPublicFieldClassNoOpt"},
|
||||||
|
{"name": "InitializeSinglePrivateFieldClassNoOpt"},
|
||||||
|
{"name": "InitializeMultiPrivateFieldClassNoOpt"},
|
||||||
|
{"name": "InitializeSingleComputedFieldClassNoOpt"},
|
||||||
|
{"name": "InitializeMultiComputedFieldClassNoOpt"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "ArrayLiteralInitialSpreadSmallDoubleHoley",
|
"name": "ArrayLiteralInitialSpreadSmallDoubleHoley",
|
||||||
"path": ["ArrayLiteralInitialSpreadSmallDoubleHoley"],
|
"path": ["ArrayLiteralInitialSpreadSmallDoubleHoley"],
|
||||||
|
Loading…
Reference in New Issue
Block a user