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 sampleData = document;
function forin() {
var result = [];
for (const key in sampleData) {
if (Object.prototype.hasOwnProperty.call(sampleData, key)) {
result.push(sampleData[key]);
}
}
return result.length;
}
function objectKeys() {
var result = [];
Object.keys(sampleData).forEach(key => {
if (Object.prototype.hasOwnProperty.call(sampleData, key)) {
result.push(sampleData[key]);
}
});
return result.length;
}
function forLoop() {
var result = [];
for (var i = 0, keys = Object.keys(sampleData); i < keys.length; i++) {
result.push(sampleData[keys[i]]);
}
return result.length;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
For...in |
| ready |
Object.keys + forEach |
| ready |
forLoop |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.