HTML Preparation code:
x
 
1
<script>
2
3
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.";
4
var re=/[\\'!"(),\-.\/:;<=>?\[\]^`{}\s‘’“”]/;
5
  
6
7
</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
        }
    };
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    split
    for loop

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0
Opera 116 on Windows
View result in a separate tab
Test name Executions per second
split 246466.4 Ops/sec
for loop 46120668.0 Ops/sec