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 comparison between using for-in loops and looping through keys given by Object.keys.
<script>
var object = (function() {
var keys = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].map(function() {
return Math.random().toString().slice(2);
});
var values = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].map(function() {
return Math.random().toString().slice(2);
});
var obj = {};
keys.forEach(function(key, index) {
obj[key] = values[index];
});
return obj;
})();
</script>
var res = {};
Ready to run.
Test | Ops/sec | |
---|---|---|
for-in |
| ready |
Object.keys |
| ready |
Object.keys (reverse order) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.