Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Firefox 66
Windows
Desktop
5 years ago
Test name Executions per second
Switch 1 case 22307848.0 Ops/sec
If-else 1 case 22031150.0 Ops/sec
Object 1 prop 31701442.0 Ops/sec
Switch 2 cases 14190528.0 Ops/sec
If-else 2 cases 14569269.0 Ops/sec
Object 2 props 31490904.0 Ops/sec
Switch 4 cases 10374292.0 Ops/sec
If-else 4 cases 10334687.0 Ops/sec
Object 4 props 30310830.0 Ops/sec
Switch 10 cases 5902114.5 Ops/sec
If-else 10 cases 6248812.5 Ops/sec
Object 10 props 28446416.0 Ops/sec
Switch 50 cases 2386490.8 Ops/sec
If-else 50 cases 2290136.5 Ops/sec
Object 50 props 29594396.0 Ops/sec
Switch 1k cases 68312.8 Ops/sec
If-else 1k cases 58210.3 Ops/sec
Object 1k props 29892774.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


;