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
speed comparissons between slice, splice, for, $.merge, Array
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
function arrayClone(arr, i) {
var copy = new Array(i);
while (i--)
copy[i] = arr[i];
return copy;
}
</script>
var a = [{
test: 'bye'
},
'z',
'a',
'q',
'w',
's',
'x',
'c',
'd',
'v',
'e',
'f',
't',
'r',
'g',
't',
'm',
'y',
'h',
't',
'y',
'j',
'i',
'o',
'l',
'f',
's',
'd',
'j',
'n'
];
var b = [];
if (b.length !== a.length) {
throw {
message: "Test failed! b.length !== a.length"
};
}
b[0].test = 'hi';
if (a[0].test === 'hi') {
// throw {message: "Not a deep clone"};
}
for (var i = 1, l = a.length; i < l; i++) {
if (b[i] !== a[i]) {
throw {
message: "Test failed! b array is " + b
};
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
slice |
| ready |
concat |
| ready |
for-unshift |
| ready |
for-push |
| ready |
for-index |
| ready |
while loop |
| ready |
slice(0) |
| ready |
a.concat() |
| ready |
Array |
| ready |
Regular For |
| ready |
arrayClone |
| ready |
map |
| ready |
For loop predefined |
| ready |
For loop predefined opt |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.