Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
ReplaceAll (regular expression, native API, split and join)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
split and join
592K/s
replaceAll
343K/s
replace with regular expression
335K/s
View exact numbers
Test name
Executions per second
✓
split and join
592,163 Ops/sec
replaceAll
342,836 Ops/sec
replace with regular expression
334,970 Ops/sec
Script Preparation code:
str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Tests:
replace with regular expression
replaced = str.replace(/\ /g, "+");
replaceAll
replaced = str.replaceAll(" ", "+");
split and join
replaced = str.split(" ").join("+");