Script Preparation code:
x
 
var random = Math.floor(Math.random() * 20);
var result = "";
var test = {
    "0": "something else",
    "1": "something else",
    "2": "something else",
    "3": "something else",
    "4": "something else",
    "5": "something else",
    "6": "something else",
    "7": "something else",
    "8": "something else",
    "9": "something else",
    "10": "something else",
    "11": "something else",
    "12": "something else",
    "13": "something else",
    "14": "something else",
    "15": "something else",
    "16": "something else",
    "17": "something else",
    "18": "something else",
    "19": "something else",
    "20": "something else"
};
function getValue(random) {
    switch (random) {
        case "0":
            return "something else";
        case "1":
            return "something else";
        case "2":
            return "something else";
        case "3":
            return "something else";
        case "4":
            return "something else";
        case "5":
            return "something else";
        case "6":
            return "something else";
        case "7":
            return "something else";
        case "8":
            return "something else";
        case "9":
            return "something else";
        case "10":
            return "something else";
        case "11":
            return "something else";
        case "12":
            return "something else";
        case "13":
            return "something else";
        case "14":
            return "something else";
        case "15":
            return "something else";
        case "16":
            return "something else";
        case "17":
            return "something else";
        case "18":
            return "something else";
        case "19":
            return "something else";
        case "20":
            return "something else";
        default:
            return "something else";
    }
};
Tests:
  • switch

     
    getValue(random);
  • dictionary

     
    test[random];
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    switch
    dictionary

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0
Firefox 137 on Windows
View result in a separate tab
Test name Executions per second
switch 37389272.0 Ops/sec
dictionary 1391940736.0 Ops/sec