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
What is most efficient when we wish to join a small beginning array with a large array in that order?
For example, I wish to concatenate [1,2,3] with [4,5,6...10000]. Is it quicker to unshift the small array onto the large one, concat them together, or push.apply the contents of the large one onto the small one?
I don't care what happens to the initial arrays, I just need a reference to the joined result.
var first = [1,2,3,4,5,6,7,8,9,10]
var second = [];
for(var i = 10; i < 10000; i++) second.push(i);
Ready to run.
Test | Ops/sec | |
---|---|---|
unshifting first array onto second |
| ready |
concatenating first and second |
| ready |
pushing contents of second array onto first |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.