Script Preparation code:
x
 
var cnt = 500 * 1024;
var str = []
for(var i=0; i < cnt; i++) {
  str.push( String.fromCharCode(Math.random() * 94 + 32) );
}
str = str.join("");
var regex = function(count) {
  var rgx = new RegExp("[\\s\\S]{1," + count + "}", "g");
  var parts = str.match(rgx);
};
var slice = function(count) {
  var parts = [];
  for(var i = 0, len = str.length; i < len; i += count) {
    parts.push( str.slice(i, i + count) );
  }
};
Tests:
  • Testing Regex, Length 1

     
    regex(1);
  • Testing Regex, Length 10

     
    regex(10);
  • Testing Regex, Length 100

     
    regex(100);
  • Testing Regex, Length 9 kB

     
    regex(9 * 1024);
  • Testing Slice, Length 1

     
    slice(1);
  • Testing Slice, Length 10

     
    slice(10);
  • Testing Slice, Length 100

     
    slice(100);
  • Testing Slice, Length 9 kB

     
    slice(9 * 1024);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Testing Regex, Length 1
    Testing Regex, Length 10
    Testing Regex, Length 100
    Testing Regex, Length 9 kB
    Testing Slice, Length 1
    Testing Slice, Length 10
    Testing Slice, Length 100
    Testing Slice, Length 9 kB

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Chrome 121 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Testing Regex, Length 1 112.6 Ops/sec
Testing Regex, Length 10 628.7 Ops/sec
Testing Regex, Length 100 1774.2 Ops/sec
Testing Regex, Length 9 kB 2232.3 Ops/sec
Testing Slice, Length 1 54.5 Ops/sec
Testing Slice, Length 10 465.4 Ops/sec
Testing Slice, Length 100 4541.1 Ops/sec
Testing Slice, Length 9 kB 479225.9 Ops/sec