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
Testing for the existence of characters in a string using Regular Expressions test, search, match and substr compared to indexOf.
<script>
var str = 'profile-test';
var re = new RegExp('^profile-', 'i');
var searchLowercased = 'profile-'.toLowerCase();
var searchLocaleLowercased = 'profile-'.toLocaleLowerCase();
function customIndexOf(haystack, needle) {
var tlen = haystack.length;
var qlen = needle.length;
var limit = tlen - qlen + 1;
searchloop: for (var i = 0; i < limit; i++) {
for (var j = 0; j < qlen; j++) {
if (haystack[j+i] != needle[j]) {
continue searchloop;
}
}
return i;
}
return -1;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
test |
| ready |
search |
| ready |
match |
| ready |
indexOf |
| ready |
indexOfLocale |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.