ProtoInherit
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var inherits = function(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
function Base() {
}
var bProto = Base.prototype;
bProto.f1 = function() {};
bProto.f2 = function() {};
bProto.f3 = function() {};
bProto.f4 = function() {};
function Child() {}
inherits(Child, Base);
var cProto = Child.prototype;
cProto.f5 = function() {};
cProto.f6 = function() {};
cProto.f7 = function() {};
cProto.f8 = function() {};
function Base1() {
this.f1 = function() {};
this.f2 = function() {};
this.f3 = function() {};
this.f4 = function() {};
}
function Child1() {
this.inheritFrom = Base1;
this.inheritFrom();
this.f5 = function() {};
this.f6 = function() {};
this.f7 = function() {};
this.f8 = function() {};
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Proto |
|
pending… |
inherits |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published
0 comments