Script Preparation code:
AخA
 
var testString = "abc.bcd.cde.def.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb.asdb"
Tests:
  • switch with includes

     
    testString.split(".").forEach(str => {
      if(["abc","bcd","cde","def"].includes(str)){
        switch(str){
            case "abc":
                console.log(str);
            case "bcd":
                console.log(str);
            case "cde":
                console.log(str);
            case "def":
                console.log(str);
            default:
        }
      }
    });
  • if-else

     
    testString.split(".").forEach(str => {
        if(str === "abc"){
           console.log(str);
        } else if(str === "bcd"){
           console.log(str);
        } else if(str === "cde"){
           console.log(str);
        } else if(str === "def"){
           console.log(str);
        } 
    });
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    switch with includes
    if-else

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 months ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 SberBrowser/21.0.0.0
Chrome 129 on Linux
View result in a separate tab
Test name Executions per second
switch with includes 22443.1 Ops/sec
if-else 50784.7 Ops/sec