Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JavaScript string split vs match using regex v2
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/133.0.0.0 Safari/537.36
Browser:
Chrome 133
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
split * 6
14420.4 Ops/sec
match * 6
21156.8 Ops/sec
replace * 6
10043.0 Ops/sec
HTML Preparation code:
<script> var getRandomIntegerInclusive = (min, max) => { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } var arr1 = "\u200b\xA0\x20\n".split(""); var str1 = "This benchmark is testing if split or match is faster on a string using regex"; var str2 = str1.replace(/\S/g, () => arr1[getRandomIntegerInclusive(0, 3)]); var regex = /[\u200b\xA0\x20\n]/g; var pxd = () => `${Math.floor(Math.random() * 314159265359 + 314159265359).toString(36)}` </script>
Tests:
split * 6
`${str2}${pxd()}`.split(regex); `${str2}${pxd()}`.split(regex); `${str2}${pxd()}`.split(regex); `${str2}${pxd()}`.split(regex); `${str2}${pxd()}`.split(regex); `${str2}${pxd()}`.split(regex);
match * 6
`${str2}${pxd()}`.match(regex); `${str2}${pxd()}`.match(regex); `${str2}${pxd()}`.match(regex); `${str2}${pxd()}`.match(regex); `${str2}${pxd()}`.match(regex); `${str2}${pxd()}`.match(regex);
replace * 6
`${str2}${pxd()}`.replace(regex,''); `${str2}${pxd()}`.replace(regex,''); `${str2}${pxd()}`.replace(regex,''); `${str2}${pxd()}`.replace(regex,''); `${str2}${pxd()}`.replace(regex,''); `${str2}${pxd()}`.replace(regex,'');