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
There are different ways of adding concat arrays. You can use array.concat or leverage the Array.prototype methods.
So, what will be faster? Array.concat because, it's build for it.. Or a prototype function?
It seems that when you need concat large arrays, the Array.prototype.push() will save you tons of time. For all other operations the array.concat would be the best option.
<script>
var arr1 = [];
var arr2 = [];
var arr3 = [];
var bigArray = new Array(100);
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
big concat |
| ready |
big Array prototype push |
| ready |
big Array prototype unshift |
| ready |
small concat |
| ready |
small Array prototype push |
| ready |
small Array prototype unshift |
| ready |
Big Array.prototye.concat |
| ready |
small Array.prototype.concat |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.