Script Preparation code:
AخA
 
function getRandomInt(max) {
    return Math.floor(Math.random() * Math.floor(max));
}
var arr = [];
for (i = 0; i < 1000; i++) {
    arr.push("PROPERTY_" + getRandomInt(10000));
    arr.push("RUS_" + getRandomInt(10000));
}
var success = 0;
Tests:
  • RegExp

     
    for(const value of arr) {
      if(/^PROPERTY_/.test(value)) success++;
    }
  • substring

     
    for(const value of arr) {
      if(value.substring(0, 9) === "PROPERTY_") success++;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    RegExp
    substring

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0
Firefox 109 on Windows
View result in a separate tab
Test name Executions per second
RegExp 2928.7 Ops/sec
substring 4927.6 Ops/sec