Script Preparation code:
x
 
var strIn = 'https://www.data-xata.com/all-servers.html';
var strOut = '';
var regex = /\.html$/;
Tests:
  • substring

     
    strOut = strIn.substring(0,strIn.length-5) + '.JS'
  • replace inline regex

     
    strOut = strIn.replace(/\.html$/, '.JS');
  • replace compiled regex var

     
    strOut = strIn.replace(regex, '.JS');
  • slice

     
    strOut = strIn.slice(0,-5) + '.JS'
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    substring
    replace inline regex
    replace compiled regex var
    slice

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Chrome 136 on Windows
View result in a separate tab
Test name Executions per second
substring 11943801.0 Ops/sec
replace inline regex 7658370.5 Ops/sec
replace compiled regex var 7772590.0 Ops/sec
slice 10923065.0 Ops/sec