jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
<script>
var augment = (function (bind, call) {
"use strict";
var bindable = Function.bindable = bind.bind(bind);
var callable = Function.callable = bindable(call);
var arrayFrom = Array.from = callable(Array.prototype.slice);
var ownPropertyOf = Object.ownPropertyOf = callable(Object.hasOwnProperty);
//Object.defineProperty(Function.prototype, "augment", augmentDescriptor);
Object.defineProperty(Object.prototype, "augment", { value: augment });
return callable(augment);
function augment(body) {
var base = typeof this === "function" ? this.prototype : this;
var prototype = Object.create(base);
body.apply(prototype, arrayFrom(arguments, 1).concat(base));
if (!ownPropertyOf(prototype, "constructor")) return prototype;
var constructor = prototype.constructor;
constructor.prototype = prototype;
return constructor;
}
}(Function.bind, Function.call));
</script>
<script>
Function.prototype.new = function () {
function functor() { return constructor.apply(this, args); }
var args = Array.prototype.slice.call(arguments);
functor.prototype = this.prototype;
var constructor = this;
return new functor;
};
function inherit() {
var len = arguments.length;
var parent = (len > 1) ? arguments[0] : Function.constructor;
var body = arguments[len - 1];
body.prototype = parent.prototype;
var constructor = new body(parent.prototype);
constructor.init.prototype = constructor;
return constructor.init;
}
function inherit2() {
var len = arguments.length;
var parent = (len > 1) ? arguments[0] : Function.constructor;
var body = arguments[len - 1];
body.prototype = parent.prototype;
var constructor = body.new.apply(body, [parent.prototype]);
constructor.init.prototype = constructor;
return constructor.init;
}
</script>
var InheritPerson = inherit(function () {
this.init = function(name) {
this.nome = name;
};
this.setAddress = function(country, city, street) {
this.country = country;
this.city = city;
this.street = street;
};
});
var InheritFrenchGuy = inherit(InheritPerson, function(base) {
this.init = function (name) {
base.init(name);
};
this.setAddress = function(city, street) {
base.setAddress("France", city, street);
};
});
var InheritParisLover = inherit(InheritFrenchGuy, function(base) {
this.init= function (name) {
base.init(name);
};
this.setAddress = function(street) {
base.setAddress("Paris", street);
return this;
};
});
var InheritPerson2 = inherit2(function () {
this.init = function(name) {
this.nome = name;
};
this.setAddress = function(country, city, street) {
this.country = country;
this.city = city;
this.street = street;
};
});
var InheritFrenchGuy2 = inherit2(InheritPerson2, function(base) {
this.init = function (name) {
base.init(name);
};
this.setAddress = function(city, street) {
base.setAddress("France", city, street);
};
});
var InheritParisLover2 = inherit2(InheritFrenchGuy2, function(base) {
this.init= function (name) {
base.init(name);
};
this.setAddress = function(street) {
base.setAddress("Paris", street);
return this;
};
});
var AugmentPerson = Object.augment(function() {
this.constructor = function (name) {
this.nome = name;
};
this.setAddress = function(country, city, street) {
this.country = country;
this.city = city;
this.street = street;
};
});
var AugmentFrenchGuy = AugmentPerson.augment(function(base) {
this.constructor = function (name) {
base.constructor(name);
};
this.setAddress = function(city, street) {
base.setAddress("France", city, street);
};
});
var AugmentParisLover = AugmentFrenchGuy.augment(function(base) {
this.constructor = function (name) {
base.constructor(name);
};
this.setAddress = function(street) {
base.setAddress("Paris", street);
return this;
};
});
Ready to run.
Test | Ops/sec | |
---|---|---|
inherit.js |
| ready |
augment.js |
| ready |
inherit2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.