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
Compare searching for a substring using indexOf and search. This assumes case-insensitive searching, so indexOf forces the strings to lower case.
Additional tests added to account for situations where the search string could contain regex characters that would consequently need to be escaped. This particular test uses the regex escape function from Google Closure, which is very similar to the one available at MDN and which may be more thorough than is generally needed.
// RegExp escape function from Closure (https://github.com/google/closure-library/blob/master/closure%2Fgoog%2Fstring%2Fstring.js#L1054)
var regExpEscape = function(s) {
return String(s).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, '\\$1').
replace(/\x08/g, '\\x08');
};
Ready to run.
Test | Ops/sec | |
---|---|---|
lowercased indexof - mid size |
| ready |
search - mid size |
| ready |
lowercased indexof - small size |
| ready |
search - small size |
| ready |
search escape - mid size |
| ready |
search escape - small size |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.