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
slightly better math
var obj = {},
arr = [],
count = 0;
for (var i = 0; i < 10000; i++) {
arr.push('wowow124.23' + i);
obj['wowow124.23' + i] = 1;
}
function in_array(needle, haystack) {
var i = haystack.length
while (i--) {
if (haystack[i] == needle)
return true;
}
return false;
}
function in_array2(needle, haystack) {
for(i=haystack.length;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 array1 (123) |
| ready |
find in array1 (1234) |
| ready |
find in array1 (9543) |
| ready |
find in array2 (123) |
| ready |
find in array2 (1234) |
| ready |
find in array2 (9543) |
| ready |
indexOf in arr(123) |
| ready |
indexOf in arr(1234) |
| ready |
indexOf in arr(9543) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.