Switchvsifelse

Benchmark created by Jonathan on


Setup

var bandwidth,
        VERY_HIGH = 'VeryHigh',
        VERY_HIGH_QUALITY = 85,
        HIGH = 'High',
        HIGH_QUALITY = 85,
        LOW = 'Low',
        LOW_QUALITY = 70,
        VERY_LOW = 'VeryLow',
        VERY_LOW_QUALITY = 60;
    
    bandwidth = VERY_LOW;

Test runner

Ready to run.

Testing in
TestOps/sec
Switch
switch (bandwidth) {
  case VERY_HIGH:
    quality = 85;
    break;
  case HIGH:
    quality = 85;
    break;
  case LOW:
    quality = 75;
    break;
  case VERY_LOW:
    quality = 70;
    break;
}
ready
If_Else
      if (bandwidth == VERY_HIGH)
        quality = VERY_HIGH_QUALITY;
      else if (bandwidth == HIGH)
        quality = HIGH_QUALITY;
      else if (bandwidth == LOW)
        quality = LOW_QUALITY;
      else if (bandwidth == VERY_LOW)
        quality = VERY_LOW_QUALITY;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Jonathan on