Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
split vs for loop
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 13; Mobile; rv:127.0) Gecko/127.0 Firefox/127.0
Browser:
Firefox Mobile 127
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
split
113769.7 Ops/sec
for loop
22082874.0 Ops/sec
HTML Preparation code:
<script> var s="Since all three methods have roughly equivalent performance, my preference is to use slice. It supports extracting from the end of the string and I feel that returning an empty string when start index > stop follows the principle of least surprise better than substring's swapping of parameters. I avoid substr because of the browser inconsistency."; var re=/[\\'!"(),\-.\/:;<=>?\[\]^`{}\s‘’“”]/; </script>
Tests:
split
var a=s.split(re); var i,l=a.lenght,w; for(i=0;i<l;i++){ w=a[i]; };
for loop
var i,l=s.lenght,w,lsp=-1; for(i=0;i<l;i++){ if(re.test(s.charAt(i))){ w=s.slice(lsp+1,i); lsp=i } };