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
searching for elements not in the array may be more telling...
var obj = {},
arr = [],
count = 0;
for (var i = 0; i < 1000; i++) {
arr.push(i);
obj[i] = 1;
}
function in_array(needle, haystack) {
for (var i = 0, maxi = haystack.length; i < maxi; ++i) {
if (haystack[i] == needle) {
return true;
}
}
return false;
}
function include(needle, haystack) {
return (haystack.indexOf(needle) != -1);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
find in array (1) |
| ready |
find in array (5) |
| ready |
find in array (9) |
| ready |
find in obj (1) |
| ready |
find in obj (5) |
| ready |
find in obj (9) |
| ready |
indexOf in arr(1) |
| ready |
indexOf in arr(5) |
| ready |
indexOf in arr(9) |
| ready |
in_array not found |
| ready |
obj not found |
| ready |
include not found |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.