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 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0
Browser:
Firefox 136
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
String.slice
775.3M/s
RegEx.exec
13.1M/s
String.replace
10.9M/s
String.match
9.6M/s
String.split
7.0M/s
View exact numbers
Test name
Executions per second
✓
String.slice
775,321,408 Ops/sec
RegEx.exec
13,078,203 Ops/sec
String.replace
10,934,309 Ops/sec
String.match
9,585,995 Ops/sec
String.split
7,003,766 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)