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 sharedPrototype = {
one: function() {
return 1;
},
two: function() {
return 2;
},
three: function() {
return 3;
}
};
var crockfordCreate = function(proto) {
var f = function() {};
f.prototype = proto;
return new f();
};
var crockfordEvolved = function (o) {
function F() {}
F.prototype = o;
return new F();
};
var Constructor = function() {};
Constructor.prototype = sharedPrototype;
</script>
<script>
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function() {
var a = false,
b = /xyz/.test(function() {
xyz
}) ? /\b_super\b/ : /.*/;
this.Class = function() {};
Class.extend = function(g) {
var f = this.prototype;
a = true;
var e = new this();
a = false;
for (var d in g) {
e[d] = typeof g[d] == "function" && typeof f[d] == "function" && b.test(g[d]) ? (function(h, i) {
return function() {
var k = this._super;
this._super = f[h];
var j = i.apply(this, arguments);
this._super = k;
return j
}
})(d, g[d]) : g[d]
}
function c() {
if (!a && this.init) {
this.init.apply(this, arguments)
}
}
c.prototype = e;
c.prototype.constructor = c;
c.extend = arguments.callee;
return c
}
})();
ResigsClass = Class.extend(sharedPrototype );
</script>
<script>
// Coffee script
/*
# original code
class Coffee
one: -> 1
two: -> 2
three: -> 3
*/
var Coffee;
Coffee = (function() {
function Coffee() {}
Coffee.prototype.one = function() {
return 1;
};
Coffee.prototype.two = function() {
return 2;
};
Coffee.prototype.three = function() {
return 3;
};
return Coffee;
})();
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Object.create() |
| ready |
Crockford Create |
| ready |
Constructor |
| ready |
Evolved |
| ready |
Resig |
| ready |
CoffeeScript |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.