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
A test of the overheads of creating objects using an object literal costs as opposed to using a predefined prototype and constructor.
<script>
function XY(x, y) {
this.x = x || 0;
this.y = y || 0;
}
XY.prototype = {
constructor: XY,
toString: function() {
return 'x: ' + this.x + ', y: ' + this.y;
}
};
function initXY(x, y) {
return {
x: x || 0,
y: y || 0
};
}
function initXYAndMethod(x, y) {
x = x || 0;
y = y || 0;
return {
x: x,
y: y,
toString: function() {
return 'x: ' + x + ', y: ' + y;
}
};
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
New Object Literal |
| ready |
New Literal with Method |
| ready |
New Predefined Class |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.