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
Comparing pure prototype code vs constructor functions
function CtorAnimal(name) {
this.name = name;
}
CtorAnimal.prototype.getName = function() {
return this.name;
};
function CtorDog(name) {
CtorAnimal.call(this, name);
}
CtorDog.prototype = Object.create(CtorAnimal.prototype);
CtorDog.prototype.speak = function() {
return "woof";
};
ProtoAnimal = Object.create(Object);
ProtoAnimal.name = "";
ProtoAnimal.getName = function() {
return this.name;
};
ProtoDog = Object.create(ProtoAnimal);
ProtoDog.speak = function() {
return "woof";
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Prototype Style |
| ready |
Constructor |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.