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
function Person1(name) {
this.name = name;
}
Person1.prototype.get_name = function() {
return this.name;
};
Person1.prototype.set_name = function(name) {
this.name = name;
};
var createPerson2 = function(name) {
var p = {
name: name
};
return {
get_name: function () {
return p.name;
},
set_name: function (name) {
p.name = name;
}
};
};
function get_name(p) {
return p.name;
}
function set_name(p, name) {
p.name = name;
}
var createPerson3 = function (name) {
var p = {
name: name
};
return {
get_name: get_name.bind(null, p),
set_name: set_name.bind(null, p),
}
};
var i;
var p1List = [];
var p2List = [];
var p3List = [];
for (i = 0; i < 10000; i += 1) {
p1List.push(new Person1('John #' + i));
p2List.push(createPerson2('John2 #' + i));
p3List.push(createPerson3('John3 #' + i));
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Prototype init |
| ready |
Closure init |
| ready |
Prototype read |
| ready |
Closure read |
| ready |
Prototype write |
| ready |
Closure write |
| ready |
Closure 2 init |
| ready |
Closure 2 read |
| ready |
Closure 2 write |
| ready |
Prototype multiple read |
| ready |
Prototype multiple write |
| ready |
Closure multiple read |
| ready |
Closure multiple write |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.