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 pts = [];
for (var i = 0; i < 1000; i++) {
pts[i] = { x: i, y: i };
}
var hardTransform = function (pt) {
return { x: pt.x * 0.5, y: pt.y + 1 };
};
var obj = {
a: 0.5,
b: 1,
_transform: function (pt) {
return { x: pt.x * this.a, y: pt.y + this.b };
},
method1: function (arr) {
return arr.map(this._transform, this);
},
method2: function (arr) {
return arr.map(hardTransform);
},
method3: function (arr) {
var res = [];
for (var i=0,len=arr.length;i<len;i++) {
res.push(this._transform(arr[i]));
}
return res;
},
method4: function (arr) {
var res = [];
for (var i=0,len=arr.length;i<len;i++) {
var pt = arr[i];
res.push({ x: pt.x * this.a, y: pt.y + this.b });
}
return res;
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
map-this |
| ready |
map-static-callback |
| ready |
loop-and-transform |
| ready |
loop-inline-transform |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.