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
test the performance of the jquery map, built-in Array.map, and native for loop map
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
testArray = new Array(500);
for(var i = 0; i < 500; i++) {
testArray[i] = i;
}
numberOp = function(x, y, z) {
return x*y;
}
stringOp = function(x, y, z) {
return "example " + x;
}
mapForLoop = function(array, mapFunction) {
var arrayLen = array.length;
var newArray = new Array(arrayLen);
for(var i = 0; i < arrayLen; i++) {
newArray[i] = mapFunction(array[i], i, array);
}
return newArray;
}
mapBuiltIn = function(array, mapFunction) {
return array.map(mapFunction);
}
mapJQuery = function(array, mapFunction) {
return $.map(array, mapFunction);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
number jquery map |
| ready |
number for loop map |
| ready |
number built in js map |
| ready |
string jquery map |
| ready |
string for loop map |
| ready |
string built-in map |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.