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
This simple test aims to compare usage of a unique RegExp or multiple IndexOf to check presence of some substrings into a string. Three pair of test is presented for respectively one substring, two substrings and four substrings.
Matches are done on several part of the string and several orders to avoid any advantages one or the other could have by the position of the match in the string, or the order of the alternatives.
<script>
var s = 'The Quick Brown Fox Jumps Over The Lazy Dog',
f;
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
IndexOf |
| ready |
RegEx |
| ready |
IndexOf - Two Alternatives |
| ready |
RegEx - Two Alternatives |
| ready |
IndexOf - Four Alternatives |
| ready |
RegEx - Four Alternatives |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.