Conditionals (if-else, ternary, switch, object-function, object-plain,object-get)

Stress testing ideas for possible and fastest condition searching
7 months ago
User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36
Test name Executions per second
Object-Function 3092662.0 Ops/sec
Object-plain 3588023.0 Ops/sec
If-Else 860784.0 Ops/sec
Ternary 752066.1 Ops/sec
Switch 3083611.0 Ops/sec
Object-Get 423700.6 Ops/sec
Tests:
  • Object-Function

  • Object-plain

  • If-Else

  • Ternary

  • Switch

  • Object-Get

Open this result on MeasureThat.net