casevsswitch (v13)

Revision 13 of this benchmark created on


Preparation HTML

<script>
  var objDictionary = {
    1 : "The string is for case 'a'",
    2 : "The string is for case 'b'",
    3 : "The string is for case 'c'",
    4 : "The string is for case 'd'",
    5 : "The string is for case 'e'",
    6 : "The string is for case 'f'",
    7 : "The string is for case 'g'",
    8 : "The string is for case 'h'",
    9 : "The string is for case 'i'",
    10 : "The string is for case 'j'"
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Lookup by object
strValue = objDictionary[10];
 
ready
Lookup by switch
strKey = 10;
switch( strKey ) {
  case 1 : 
    strResult = "The string is for case 'a'";
    break;
    
  case 2 : 
    strResult = "The string is for case 'b'";
    break;
    
  case 3 : 
    strResult = "The string is for case 'c'";
    break;
    
  case 4 : 
    strResult = "The string is for case 'd'";
    break;
    
  case 5 : 
    strResult = "The string is for case 'e'";
    break;
    
  case 6 : 
    strResult = "The string is for case 'f'";
    break;
    
  case 7 : 
    strResult = "The string is for case 'g'";
    break;
    
  case 8 : 
    strResult = "The string is for case 'h'";
    break;
    
  case 9 : 
    strResult = "The string is for case 'i'";
    break;
    
  case 10 : 
    strResult = "The string is for case 'j'";
    break;
}
ready

Revisions

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