Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36
Chrome 90
Linux
Desktop
3 years ago
Test name Executions per second
Switch 1 case 3504915.5 Ops/sec
If-else 1 case 2631708.0 Ops/sec
Object 1 prop 1711863.4 Ops/sec
Switch 2 cases 2292707.2 Ops/sec
If-else 2 cases 2659004.5 Ops/sec
Object 2 props 2492180.8 Ops/sec
Switch 4 cases 2417090.2 Ops/sec
If-else 4 cases 2483783.5 Ops/sec
Object 4 props 2571652.5 Ops/sec
Switch 10 cases 2626742.2 Ops/sec
If-else 10 cases 2983515.8 Ops/sec
Object 10 props 3478808.2 Ops/sec
Switch 50 cases 2607190.8 Ops/sec
If-else 50 cases 2664374.5 Ops/sec
Object 50 props 3651199.0 Ops/sec
Switch 1k cases 322066.0 Ops/sec
If-else 1k cases 270093.6 Ops/sec
Object 1k props 2970740.0 Ops/sec
Script Preparation code:
Tests:
  • Switch 1 case

  • Switch 1k cases

  • Object 50 props

  • If-else 50 cases

  • Switch 50 cases

  • Object 10 props

  • If-else 10 cases

  • Switch 10 cases

  • Object 4 props

  • If-else 4 cases

  • Switch 4 cases

  • Object 2 props

  • If-else 2 cases

  • Switch 2 cases

  • Object 1 prop

  • If-else 1 case

  • If-else 1k cases

  • Object 1k props


;