Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0
Chrome 127
Linux
Desktop
9 months ago
Test name Executions per second
String.split 140448.9 Ops/sec
Regex.match 639814.1 Ops/sec
Script Preparation code:
AخA
 
string = "This is a benchmark to test if matching a regex is faster that splitting a string";
regex = /\S+/gi;
Tests:
  • String.split

     
    string.split(/|s/)
  • Regex.match

     
    string.match(regex)