Script Preparation code:
AخA
 
var animal = "dog"
Tests:
  • Switch

    x
     
    function test(animal) {
      switch(animal){
       case 'cat': return 'Kitten'
       case 'cattle': return 'Calf'
       case 'cheetah': return 'Cub'
       case 'dog': return 'Pup'
       default: return "I don't know that"
    }
    }
    console.log(test(animal))
  • Object Literal

     
    function test(animal) {
      var babyAnimal = {
       cat:'Kitten',
       cattle:'Calf',
       cheetah:'Cub',
       dog:'Pup'
    }
    return babyAnimal[animal] ?? "I don't know that"
    }
    console.log(test(animal))
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Switch
    Object Literal

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Android 11; Mobile; rv:102.0) Gecko/102.0 Firefox/102.0
Firefox Mobile 102 on Android
View result in a separate tab
Test name Executions per second
Switch 47939.3 Ops/sec
Object Literal 43926.8 Ops/sec