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
Is it faster to remove an item from an array (and thus allow the indices to be renumbered) or delete a property from an object. Also, checking deletion from array, but this does not renumber the indices so may not be preferable.
<script>
var count = 100000;
var deleteInc = 100;
</script>
var someArr = [];
var someObj = {};
var someObjWithIntegerKeys = {};
for(var i = 0; i < count; i++)
{
someArr[i] = Math.floor(Math.random() * 1000000);
someObj['a' + i] = Math.floor(Math.random() * 1000000);
someObjWithIntegerKeys[i] = Math.floor(Math.random() * 1000000);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Splice |
| ready |
Object Delete String Keys |
| ready |
Object Delete Integer Keys |
| ready |
Array Delete |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.