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
This page tests speed of two different methods for array concatenation. Array method concat() has no side effects (it creates a new array to store its result in), while Array.prototype.push.apply(A, [1, 2, ...]) extends the array A.
<script>
var x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
y = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
var arrPush = Array.prototype.push;
var push_array = function(x,b){
var a = x.slice(0),
bl = b.length,
al = a.length,
i = 0;
while (i < bl) {
a[al++] = b[i++];
}
return a;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
concat |
| ready |
Array#push.apply |
| ready |
Array#push with loop |
| ready |
Cached Array#push |
| ready |
Splice |
| ready |
Array#push with loop while |
| ready |
| ready | |
last test |
| ready |
apply |
| ready |
just slice |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.