Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
replaceAll vs regex replace vs split&join
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/25.0 Chrome/121.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 121
Operating system:
Android
Device Platform:
Mobile
Date tested:
2 years ago
split&join
3.9M/s
replace regex
3.3M/s
replace All
1.2M/s
View exact numbers
Test name
Executions per second
✓
split&join
3,931,519 Ops/sec
replace regex
3,327,023 Ops/sec
replace All
1,189,674 Ops/sec
Script Preparation code:
String.prototype.replaceAll = function(search, replacement) { var target = this; return target.replace(new RegExp(search, 'g'), replacement); };
Tests:
replace regex
"this {a} is {a} it".replace(/\{a\}/g, "+");
replace All
"this {a} is {a} it".replaceAll("{a}", "+");
split&join
"this {a} is {a} it".split('{a}').join('+');