[js-perf-test] Add microbenchmarks for leaf constructors.
Bug: v8:6679 Change-Id: I1fff8ffa037629636f31ecd2b731f5b9de89ce44 Reviewed-on: https://chromium-review.googlesource.com/604789 Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#47209}
This commit is contained in:
parent
6ee1996153
commit
f2c702743c
31
test/js-perf-test/Classes/leaf-constructors.js
Normal file
31
test/js-perf-test/Classes/leaf-constructors.js
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
'use strict';
|
||||
|
||||
var DefaultConstructorBenchmark = new BenchmarkSuite('LeafConstructors',
|
||||
[100], [
|
||||
new Benchmark('WithExplicitArguments', false, false, 0,
|
||||
WithExplicitArguments),
|
||||
]);
|
||||
|
||||
|
||||
const Point = class Point {
|
||||
constructor(x, y, z) { this.x = x; this.y = y; this.z = z; }
|
||||
}
|
||||
|
||||
const klasses = [
|
||||
class A extends Point { constructor(x, y, z) { super(x, y, z); } },
|
||||
class B extends Point { constructor(x, y, z) { super(x, y, z); } },
|
||||
class C extends Point { constructor(x, y, z) { super(x, y, z); } },
|
||||
class D extends Point { constructor(x, y, z) { super(x, y, z); } },
|
||||
class E extends Point { constructor(x, y, z) { super(x, y, z); } }
|
||||
];
|
||||
|
||||
function WithExplicitArguments() {
|
||||
let result = null;
|
||||
for (const klass of klasses) {
|
||||
result = new klass(0, 1, 2);
|
||||
}
|
||||
return result;
|
||||
};
|
@ -6,6 +6,7 @@
|
||||
load('../base.js');
|
||||
load('super.js');
|
||||
load('default-constructor.js');
|
||||
load('leaf-constructors.js');
|
||||
|
||||
|
||||
var success = true;
|
||||
|
@ -84,11 +84,15 @@
|
||||
"name": "Classes",
|
||||
"path": ["Classes"],
|
||||
"main": "run.js",
|
||||
"resources": ["super.js", "default-constructor.js"],
|
||||
"resources": [
|
||||
"super.js",
|
||||
"default-constructor.js",
|
||||
"leaf-constructors.js"],
|
||||
"results_regexp": "^%s\\-Classes\\(Score\\): (.+)$",
|
||||
"tests": [
|
||||
{"name": "Super"},
|
||||
{"name": "DefaultConstructor"}
|
||||
{"name": "DefaultConstructor"},
|
||||
{"name": "LeafConstructors"}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user