Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
test regex vs loop
test regex vs loop
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:148.0) Gecko/20100101 Firefox/148.0
Browser:
Firefox 148
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
regex
474708.9 Ops/sec
loop
247430.6 Ops/sec
Tests:
regex
const regex = /(00|11|22|33|44|55|66|77|88|99)/; let num = 3298; num = num + 1; let aux = (num).toString(); while (regex.test(aux)) { num += 1; aux = num.toString(); }
loop
let num = 3298; const consecutiveChars = function(num) { const arr = num.toString().split(''); for (let idx = 0; idx < arr.length - 1; idx++) { if (arr[idx] == arr[idx + 1]) return true; } return false; } num = num + 1; while (consecutiveChars(num)) { num++; }