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, and match compared to indexOf.
<script>
var str = "But I must explain to you how all this mistaken idea of denouncing of a pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure";
var match = 'again';
</script>
var precompiledRegex = /(again)/g;
Ready to run.
Test | Ops/sec | |
---|---|---|
test |
| ready |
search |
| ready |
match |
| ready |
indexOf |
| ready |
precompiled test |
| ready |
precompiled search |
| ready |
precompiled match |
| ready |
indexOf string primitive |
| ready |
Primitive comparison |
| ready |
Substring |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.