Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
replace with global regexp vs replaceAll vs split-join
(version: 1)
Comparing performance of:
replace with global regexp vs replaceAll vs split-join
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
replace with global regexp
"i want to replace all the spaces in this string".replace(/ /g, "_");
replaceAll
"i want to replace all the spaces in this string".replaceAll(" ", "_");
split-join
"i want to replace all the spaces in this string".split(" ").join("_");
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
replace with global regexp
replaceAll
split-join
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15
Browser/OS:
Safari 26 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
replace with global regexp
613535872.0 Ops/sec
replaceAll
6661377.5 Ops/sec
split-join
15065213.0 Ops/sec
Related benchmarks:
String.replace vs String.replaceAll
replaceAll vs regex vs split-join replace competition
replaceAll vs regex replace vs string split join
replaceAll vs regex replace vs string split join including longer test cases
replaceAll vs regex replace string
Replace regex x replaceAll
replace with global regexp vs replaceAll
split-join vs regex replace vs replaceAll
replace with global regexp vs replaceAll vs split-join v2
Comments
Confirm delete:
Do you really want to delete benchmark?