switch-vs-hash (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script>
  var s = ["hpaj", "afsr", "bcq", "lnpz", "lzz", "ioyir", "wbjm", "wcub", "zfgaa", "zbj", "psj", "ftdum", "xcsu", "tujz", "bhjn", "xuapk", "bnvdq", "wfvf", "qibq", "wkty", "rvb", "xktq", "toit", "xpyo", "pggdi", "nupst", "gdmz", "puft", "snlmy", "dayj", "dfkw", "say", "opftk", "mjid", "guvg", "hcww", "udghy", "epved", "jbe", "vef", "mveu", "szix", "ujldn", "lvr", "ndrck", "qpnj", "dcjb", "xcazr", "ibgd", "mfptd", "qyrv", "sjamf", "xroov", "nafk", "kwbx", "eybjv", "mfx", "meatm", "taa", "cajz", "svgc", "kpmh", "fyyn", "mpakf", "kymv", "yrn", "hqt", "hftl", "irket", "xfhfh", "pviu", "gizv", "bogsu", "any", "vlr", "zer", "xidsf", "lfg", "mjh", "rovw", "rwws", "bkr", "eke", "qtcw", "espbl", "dyh", "bhdt", "tomdn", "pfxb", "mhkil", "uvx", "rixob", "cjfh", "vkn", "rnwdm", "ssu", "qctb", "kpcp", "vwyp", "dosnq"];
  var r = [];
  
  var templates = {
  
   "hpaj": function(r) {
    r.push("hpaj");
   },
  
   "afsr": function(r) {
    r.push("afsr");
   },
  
   "bcq": function(r) {
    r.push("bcq");
   },
  
   "lnpz": function(r) {
    r.push("lnpz");
   },
  
   "lzz": function(r) {
    r.push("lzz");
   },
  
   "ioyir": function(r) {
    r.push("ioyir");
   },
  
   "wbjm": function(r) {
    r.push("wbjm");
   },
  
   "wcub": function(r) {
    r.push("wcub");
   },
  
   "zfgaa": function(r) {
    r.push("zfgaa");
   },
  
   "zbj": function(r) {
    r.push("zbj");
   },
  
   "psj": function(r) {
    r.push("psj");
   },
  
   "ftdum": function(r) {
    r.push("ftdum");
   },
  
   "xcsu": function(r) {
    r.push("xcsu");
   },
  
   "tujz": function(r) {
    r.push("tujz");
   },
  
   "bhjn": function(r) {
    r.push("bhjn");
   },
  
   "xuapk": function(r) {
    r.push("xuapk");
   },
  
   "bnvdq": function(r) {
    r.push("bnvdq");
   },
  
   "wfvf": function(r) {
    r.push("wfvf");
   },
  
   "qibq": function(r) {
    r.push("qibq");
   },
  
   "wkty": function(r) {
    r.push("wkty");
   },
  
   "rvb": function(r) {
    r.push("rvb");
   },
  
   "xktq": function(r) {
    r.push("xktq");
   },
  
   "toit": function(r) {
    r.push("toit");
   },
  
   "xpyo": function(r) {
    r.push("xpyo");
   },
  
   "pggdi": function(r) {
    r.push("pggdi");
   },
  
   "nupst": function(r) {
    r.push("nupst");
   },
  
   "gdmz": function(r) {
    r.push("gdmz");
   },
  
   "puft": function(r) {
    r.push("puft");
   },
  
   "snlmy": function(r) {
    r.push("snlmy");
   },
  
   "dayj": function(r) {
    r.push("dayj");
   },
  
   "dfkw": function(r) {
    r.push("dfkw");
   },
  
   "say": function(r) {
    r.push("say");
   },
  
   "opftk": function(r) {
    r.push("opftk");
   },
  
   "mjid": function(r) {
    r.push("mjid");
   },
  
   "guvg": function(r) {
    r.push("guvg");
   },
  
   "hcww": function(r) {
    r.push("hcww");
   },
  
   "udghy": function(r) {
    r.push("udghy");
   },
  
   "epved": function(r) {
    r.push("epved");
   },
  
   "jbe": function(r) {
    r.push("jbe");
   },
  
   "vef": function(r) {
    r.push("vef");
   },
  
   "mveu": function(r) {
    r.push("mveu");
   },
  
   "szix": function(r) {
    r.push("szix");
   },
  
   "ujldn": function(r) {
    r.push("ujldn");
   },
  
   "lvr": function(r) {
    r.push("lvr");
   },
  
   "ndrck": function(r) {
    r.push("ndrck");
   },
  
   "qpnj": function(r) {
    r.push("qpnj");
   },
  
   "dcjb": function(r) {
    r.push("dcjb");
   },
  
   "xcazr": function(r) {
    r.push("xcazr");
   },
  
   "ibgd": function(r) {
    r.push("ibgd");
   },
  
   "mfptd": function(r) {
    r.push("mfptd");
   },
  
   "qyrv": function(r) {
    r.push("qyrv");
   },
  
   "sjamf": function(r) {
    r.push("sjamf");
   },
  
   "xroov": function(r) {
    r.push("xroov");
   },
  
   "nafk": function(r) {
    r.push("nafk");
   },
  
   "kwbx": function(r) {
    r.push("kwbx");
   },
  
   "eybjv": function(r) {
    r.push("eybjv");
   },
  
   "mfx": function(r) {
    r.push("mfx");
   },
  
   "meatm": function(r) {
    r.push("meatm");
   },
  
   "taa": function(r) {
    r.push("taa");
   },
  
   "cajz": function(r) {
    r.push("cajz");
   },
  
   "svgc": function(r) {
    r.push("svgc");
   },
  
   "kpmh": function(r) {
    r.push("kpmh");
   },
  
   "fyyn": function(r) {
    r.push("fyyn");
   },
  
   "mpakf": function(r) {
    r.push("mpakf");
   },
  
   "kymv": function(r) {
    r.push("kymv");
   },
  
   "yrn": function(r) {
    r.push("yrn");
   },
  
   "hqt": function(r) {
    r.push("hqt");
   },
  
   "hftl": function(r) {
    r.push("hftl");
   },
  
   "irket": function(r) {
    r.push("irket");
   },
  
   "xfhfh": function(r) {
    r.push("xfhfh");
   },
  
   "pviu": function(r) {
    r.push("pviu");
   },
  
   "gizv": function(r) {
    r.push("gizv");
   },
  
   "bogsu": function(r) {
    r.push("bogsu");
   },
  
   "any": function(r) {
    r.push("any");
   },
  
   "vlr": function(r) {
    r.push("vlr");
   },
  
   "zer": function(r) {
    r.push("zer");
   },
  
   "xidsf": function(r) {
    r.push("xidsf");
   },
  
   "lfg": function(r) {
    r.push("lfg");
   },
  
   "mjh": function(r) {
    r.push("mjh");
   },
  
   "rovw": function(r) {
    r.push("rovw");
   },
  
   "rwws": function(r) {
    r.push("rwws");
   },
  
   "bkr": function(r) {
    r.push("bkr");
   },
  
   "eke": function(r) {
    r.push("eke");
   },
  
   "qtcw": function(r) {
    r.push("qtcw");
   },
  
   "espbl": function(r) {
    r.push("espbl");
   },
  
   "dyh": function(r) {
    r.push("dyh");
   },
  
   "bhdt": function(r) {
    r.push("bhdt");
   },
  
   "tomdn": function(r) {
    r.push("tomdn");
   },
  
   "pfxb": function(r) {
    r.push("pfxb");
   },
  
   "mhkil": function(r) {
    r.push("mhkil");
   },
  
   "uvx": function(r) {
    r.push("uvx");
   },
  
   "rixob": function(r) {
    r.push("rixob");
   },
  
   "cjfh": function(r) {
    r.push("cjfh");
   },
  
   "vkn": function(r) {
    r.push("vkn");
   },
  
   "rnwdm": function(r) {
    r.push("rnwdm");
   },
  
   "ssu": function(r) {
    r.push("ssu");
   },
  
   "qctb": function(r) {
    r.push("qctb");
   },
  
   "kpcp": function(r) {
    r.push("kpcp");
   },
  
   "vwyp": function(r) {
    r.push("vwyp");
   },
  
   "dosnq": function(r) {
    r.push("dosnq");
   }
  
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
switch
switch (s[Math.floor(Math.random() * s.length)]) {
case "hpaj":
 r.push("hpaj");
 break;
case "afsr":
 r.push("afsr");
 break;
case "bcq":
 r.push("bcq");
 break;
case "lnpz":
 r.push("lnpz");
 break;
case "lzz":
 r.push("lzz");
 break;
case "ioyir":
 r.push("ioyir");
 break;
case "wbjm":
 r.push("wbjm");
 break;
case "wcub":
 r.push("wcub");
 break;
case "zfgaa":
 r.push("zfgaa");
 break;
case "zbj":
 r.push("zbj");
 break;
case "psj":
 r.push("psj");
 break;
case "ftdum":
 r.push("ftdum");
 break;
case "xcsu":
 r.push("xcsu");
 break;
case "tujz":
 r.push("tujz");
 break;
case "bhjn":
 r.push("bhjn");
 break;
case "xuapk":
 r.push("xuapk");
 break;
case "bnvdq":
 r.push("bnvdq");
 break;
case "wfvf":
 r.push("wfvf");
 break;
case "qibq":
 r.push("qibq");
 break;
case "wkty":
 r.push("wkty");
 break;
case "rvb":
 r.push("rvb");
 break;
case "xktq":
 r.push("xktq");
 break;
case "toit":
 r.push("toit");
 break;
case "xpyo":
 r.push("xpyo");
 break;
case "pggdi":
 r.push("pggdi");
 break;
case "nupst":
 r.push("nupst");
 break;
case "gdmz":
 r.push("gdmz");
 break;
case "puft":
 r.push("puft");
 break;
case "snlmy":
 r.push("snlmy");
 break;
case "dayj":
 r.push("dayj");
 break;
case "dfkw":
 r.push("dfkw");
 break;
case "say":
 r.push("say");
 break;
case "opftk":
 r.push("opftk");
 break;
case "mjid":
 r.push("mjid");
 break;
case "guvg":
 r.push("guvg");
 break;
case "hcww":
 r.push("hcww");
 break;
case "udghy":
 r.push("udghy");
 break;
case "epved":
 r.push("epved");
 break;
case "jbe":
 r.push("jbe");
 break;
case "vef":
 r.push("vef");
 break;
case "mveu":
 r.push("mveu");
 break;
case "szix":
 r.push("szix");
 break;
case "ujldn":
 r.push("ujldn");
 break;
case "lvr":
 r.push("lvr");
 break;
case "ndrck":
 r.push("ndrck");
 break;
case "qpnj":
 r.push("qpnj");
 break;
case "dcjb":
 r.push("dcjb");
 break;
case "xcazr":
 r.push("xcazr");
 break;
case "ibgd":
 r.push("ibgd");
 break;
case "mfptd":
 r.push("mfptd");
 break;
case "qyrv":
 r.push("qyrv");
 break;
case "sjamf":
 r.push("sjamf");
 break;
case "xroov":
 r.push("xroov");
 break;
case "nafk":
 r.push("nafk");
 break;
case "kwbx":
 r.push("kwbx");
 break;
case "eybjv":
 r.push("eybjv");
 break;
case "mfx":
 r.push("mfx");
 break;
case "meatm":
 r.push("meatm");
 break;
case "taa":
 r.push("taa");
 break;
case "cajz":
 r.push("cajz");
 break;
case "svgc":
 r.push("svgc");
 break;
case "kpmh":
 r.push("kpmh");
 break;
case "fyyn":
 r.push("fyyn");
 break;
case "mpakf":
 r.push("mpakf");
 break;
case "kymv":
 r.push("kymv");
 break;
case "yrn":
 r.push("yrn");
 break;
case "hqt":
 r.push("hqt");
 break;
case "hftl":
 r.push("hftl");
 break;
case "irket":
 r.push("irket");
 break;
case "xfhfh":
 r.push("xfhfh");
 break;
case "pviu":
 r.push("pviu");
 break;
case "gizv":
 r.push("gizv");
 break;
case "bogsu":
 r.push("bogsu");
 break;
case "any":
 r.push("any");
 break;
case "vlr":
 r.push("vlr");
 break;
case "zer":
 r.push("zer");
 break;
case "xidsf":
 r.push("xidsf");
 break;
case "lfg":
 r.push("lfg");
 break;
case "mjh":
 r.push("mjh");
 break;
case "rovw":
 r.push("rovw");
 break;
case "rwws":
 r.push("rwws");
 break;
case "bkr":
 r.push("bkr");
 break;
case "eke":
 r.push("eke");
 break;
case "qtcw":
 r.push("qtcw");
 break;
case "espbl":
 r.push("espbl");
 break;
case "dyh":
 r.push("dyh");
 break;
case "bhdt":
 r.push("bhdt");
 break;
case "tomdn":
 r.push("tomdn");
 break;
case "pfxb":
 r.push("pfxb");
 break;
case "mhkil":
 r.push("mhkil");
 break;
case "uvx":
 r.push("uvx");
 break;
case "rixob":
 r.push("rixob");
 break;
case "cjfh":
 r.push("cjfh");
 break;
case "vkn":
 r.push("vkn");
 break;
case "rnwdm":
 r.push("rnwdm");
 break;
case "ssu":
 r.push("ssu");
 break;
case "qctb":
 r.push("qctb");
 break;
case "kpcp":
 r.push("kpcp");
 break;
case "vwyp":
 r.push("vwyp");
 break;
case "dosnq":
 r.push("dosnq");
 break;
}
ready
hash
templates[s[Math.floor(Math.random() * s.length)]](r);
ready
common
Math.floor(Math.random() * s.length);
r.push("bcq");
ready

Revisions

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