Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
Firefox 60
Linux
Desktop
5 years ago
Test name Executions per second
Switch 1 case 24557696.0 Ops/sec
If-else 1 case 20128256.0 Ops/sec
Object 1 prop 33119584.0 Ops/sec
Switch 2 cases 14432544.0 Ops/sec
If-else 2 cases 15286225.0 Ops/sec
Object 2 props 33817624.0 Ops/sec
Switch 4 cases 10792797.0 Ops/sec
If-else 4 cases 11934214.0 Ops/sec
Object 4 props 32328752.0 Ops/sec
Switch 10 cases 6524143.0 Ops/sec
If-else 10 cases 6681113.0 Ops/sec
Object 10 props 33841528.0 Ops/sec
Switch 50 cases 2567835.5 Ops/sec
If-else 50 cases 2439643.2 Ops/sec
Object 50 props 32011830.0 Ops/sec
Switch 1k cases 40180.5 Ops/sec
If-else 1k cases 30716.5 Ops/sec
Object 1k props 31707590.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


;