v8/test/js-perf-test/SuperIC/monomorphic-mega-receivers.js
Marja Hölttä a6b38d817c [super property speed] Add js-perf-tests for super property access
Bug: v8:9237
No-Try: True
Change-Id: Ic1bba1e0f5584350217c3971dfcc769c86beb1fd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2366694
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69538}
2020-08-24 12:20:49 +00:00

56 lines
1.1 KiB
JavaScript

// Copyright 2020 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.
const DETERMINISTIC_RUNS = 10000;
new BenchmarkSuite('Monomorphic-MegaReceivers', [1000], [
new Benchmark('Monomorphic-MegaReceivers', false, false, DETERMINISTIC_RUNS,
runBenchmark)
]);
class A { };
A.prototype.super_prop = 10;
class B extends A {
test() {
return super.super_prop;
}
};
class C0 extends B { };
class C1 extends B { };
class C2 extends B { };
class C3 extends B { };
class C4 extends B { };
class C5 extends B { };
class C6 extends B { };
class C7 extends B { };
class C8 extends B { };
class C9 extends B { };
const objects = [
new C0(),
new C1(),
new C2(),
new C3(),
new C4(),
new C5(),
new C6(),
new C7(),
new C8(),
new C9(),
];
let ix = 0;
const EXPECTED_VALUE = 10;
function runBenchmark() {
const r = objects[ix].test();
if (r != EXPECTED_VALUE) {
throw new Error("Test error");
}
if (++ix == objects.length) {
ix = 0;
}
}