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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser:
Chrome 143
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
6 months ago
String.slice
172.4M/s
String.split
41.8M/s
String.replace
36.5M/s
RegEx.exec
28.3M/s
String.match
28.0M/s
View exact numbers
Test name
Executions per second
✓
String.slice
172,400,976 Ops/sec
String.split
41,768,676 Ops/sec
String.replace
36,510,284 Ops/sec
RegEx.exec
28,289,318 Ops/sec
String.match
28,030,280 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)