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
var inherit = function(obj) { // make a dummy object that has prototype as obj
var F = function () {};
F.prototype = obj;
return new F();
};
var Shape = function (color) { // constructor
this.color = color;
};
Shape.prototype.get_color = function () {
return this.color;
};
Shape.prototype.area = function() {
return 0.0;
};
var Rectangle = function (color, height, width) {
Shape.apply(this, [color]);
this.height = height;
this.width = width;
};
Rectangle.prototype = inherit(Shape.prototype);
Rectangle.prototype.area = function () {
return this.height * this.width;
};
var shape = function (color) {
var that = {};
that.get_color = function () {
return color;
};
that.area = function () {
return 0.0;
};
return that;
};
var rectangle = function (color, height, width) {
var that = shape(color);
that.area = function () {
return height * width;
};
return that;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Prototypal |
| ready |
Module pattern |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.