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
check the number of occurrences of a single number in a string of numbers
loremIpsumLines = [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Nam eu facilisis ante.",
"Proin vel massa nec nisl lobortis eleifend id a lectus.",
"Cras dictum sollicitudin magna, eu ultricies sapien congue quis.",
"Suspendisse potenti. Morbi ac orci diam. Cras aliquam, magna in suscipit volutpat, velit dui iaculis purus, in elementum risus arcu ut metus.",
"Etiam adipiscing tincidunt arcu ac faucibus. Etiam aliquet, velit non auctor consequat, odio nunc malesuada massa, id consequat lacus nunc a est.",
"Suspendisse pulvinar velit et neque facilisis quis congue nisl rhoncus. Pellentesque auctor iaculis orci ornare congue.",
"Nam in nunc eros, quis condimentum turpis. In commodo, velit quis laoreet iaculis, mi leo commodo dolor, sit amet pretium libero tellus et massa."];
loremIpsum = loremIpsumLines.join("\n");
countChars1 = function(text) {
text.match(/q/g).length;
}
countChars2 = function(text) {
text.split("q").length - 1
}
regex = new RegExp("q","g")
countChars3 = function(text) {
text.match(regex).length;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
regular expression |
| ready |
split |
| ready |
Precompiled regex |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.