Chromium Code Reviews| Index: test/js-perf-test/Classes/super.js |
| diff --git a/test/js-perf-test/Classes/super.js b/test/js-perf-test/Classes/super.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..01dff04174369e05c98872ed09b24dd3600b7222 |
| --- /dev/null |
| +++ b/test/js-perf-test/Classes/super.js |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2014 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 SuperBenchmark = new BenchmarkSuite('Super', [1000], [ |
| + new Benchmark('SuperMethodCall', false, false, 0, SuperMethodCall), |
| + new Benchmark('SuperGetterCall', false, false, 0, SuperGetterCall), |
| + new Benchmark('SuperSetterCall', false, false, 0, SuperSetterCall), |
| +]); |
| + |
| + |
| +function Base() { } |
| +function Derived() { |
| + this._x = 1; |
| +} |
| + |
| + |
| +Base.prototype = { |
| + constructor: Base, |
| + get x() { |
| + return this._x++; |
| + }, |
| + set x(v) { |
| + this._x += v; |
| + return this._x; |
| + } |
| +} |
| + |
| +Base.prototype.f = function() { |
| + return this._x++; |
| +}.toMethod(Base.prototype); |
| + |
| +Derived.prototype = Object.create(Base.prototype); |
| + |
| +Derived.prototype.SuperCall = function() { |
| + return super.f(); |
| +}.toMethod(Derived.prototype); |
| + |
| +Derived.prototype.GetterCall = function() { |
| + return super.x; |
| +}.toMethod(Derived.prototype); |
| + |
| +Derived.prototype.SetterCall = function() { |
| + return super.x = 5; |
| +}.toMethod(Derived.prototype); |
| + |
|
arv (Not doing code reviews)
2014/10/16 19:36:55
Object.setPrototypeOf(Derived, Base)
too? Since t
Dmitry Lomov (no reviews)
2014/10/16 19:43:29
Done.
|
| +var derived = new Derived(); |
| + |
| +function SuperMethodCall() { |
| + return derived.SuperCall(); |
| +} |
| + |
| +function SuperGetterCall() { |
| + return derived.GetterCall(); |
| +} |
| + |
| +function SuperSetterCall() { |
| + return derived.SetterCall(); |
| +} |