Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
split vs exec vs replace vs slice
Test String.split vs RegEx.exec (and String.match) vs String.replace vs String.slice
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0
Browser:
Chrome 149
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one month ago
String.slice
288.7M/s
String.replace
42.5M/s
String.split
41.4M/s
RegEx.exec
36.3M/s
String.match
33.7M/s
View exact numbers
Test name
Executions per second
✓
String.slice
288,664,096 Ops/sec
String.replace
42,458,320 Ops/sec
String.split
41,377,128 Ops/sec
RegEx.exec
36,291,884 Ops/sec
String.match
33,713,112 Ops/sec
Script Preparation code:
str = "1875 Tokens"; re = /(\d+)\sTokens/;
Tests:
String.split
str.split(" ")[0]
String.match
str.match(re)[1]
RegEx.exec
re.exec(str)[1]
String.replace
str.replace(' Tokens', '')
String.slice
str.slice(0, -7)