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 inherit() {
var len = arguments.length;
var parent = (len > 1) ? arguments[0] : Function.constructor;
var body = arguments[len - 1];
var constructor = new body(parent.prototype);
constructor.constructor.prototype = constructor;
return constructor.constructor;
}
</script>
var InheritPerson = inherit(function () {
this.constructor= 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.constructor= function (name) {
base.constructor.call(this,name);
};
this.setAddress = function(city, street) {
base.setAddress.call(this,"France", city, street);
};
});
var InheritParisLover = inherit(InheritFrenchGuy, function(base) {
this.constructor= function (name) {
base.constructor.call(this,name);
};
this.setAddress = function(street) {
base.setAddress.call(this,"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.call(this,name);
};
this.setAddress = function(city, street) {
base.setAddress.call(this,"France", city, street);
};
});
var AugmentParisLover = AugmentFrenchGuy.augment(function(base) {
this.constructor = function (name) {
base.constructor.call(this,name);
};
this.setAddress = function(street) {
base.setAddress.call(this,"Paris", street);
return this;
};
});
Ready to run.
Test | Ops/sec | |
---|---|---|
inherit.js |
| ready |
augment.js |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.