Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Read Data Table vs Switch
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Windows
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
Switch
21.3 Ops/sec
Table
29.4 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
// 100 symbols (key) const CONST_00 = Symbol("0"); const CONST_01 = Symbol("1"); const CONST_02 = Symbol("2"); const CONST_03 = Symbol("3"); const CONST_04 = Symbol("4"); const CONST_05 = Symbol("5"); const CONST_06 = Symbol("6"); const CONST_07 = Symbol("7"); const CONST_08 = Symbol("8"); const CONST_09 = Symbol("9"); const CONST_10 = Symbol("10"); const CONST_11 = Symbol("11"); const CONST_12 = Symbol("12"); const CONST_13 = Symbol("13"); const CONST_14 = Symbol("14"); const CONST_15 = Symbol("15"); const CONST_16 = Symbol("16"); const CONST_17 = Symbol("17"); const CONST_18 = Symbol("18"); const CONST_19 = Symbol("19"); const CONST_20 = Symbol("20"); const CONST_21 = Symbol("21"); const CONST_22 = Symbol("22"); const CONST_23 = Symbol("23"); const CONST_24 = Symbol("24"); const CONST_25 = Symbol("25"); const CONST_26 = Symbol("26"); const CONST_27 = Symbol("27"); const CONST_28 = Symbol("28"); const CONST_29 = Symbol("29"); const CONST_30 = Symbol("30"); const CONST_31 = Symbol("31"); const CONST_32 = Symbol("32"); const CONST_33 = Symbol("33"); const CONST_34 = Symbol("34"); const CONST_35 = Symbol("35"); const CONST_36 = Symbol("36"); const CONST_37 = Symbol("37"); const CONST_38 = Symbol("38"); const CONST_39 = Symbol("39"); const CONST_40 = Symbol("40"); const CONST_41 = Symbol("41"); const CONST_42 = Symbol("42"); const CONST_43 = Symbol("43"); const CONST_44 = Symbol("44"); const CONST_45 = Symbol("45"); const CONST_46 = Symbol("46"); const CONST_47 = Symbol("47"); const CONST_48 = Symbol("48"); const CONST_49 = Symbol("49"); const CONST_50 = Symbol("50"); const CONST_51 = Symbol("51"); const CONST_52 = Symbol("52"); const CONST_53 = Symbol("53"); const CONST_54 = Symbol("54"); const CONST_55 = Symbol("55"); const CONST_56 = Symbol("56"); const CONST_57 = Symbol("57"); const CONST_58 = Symbol("58"); const CONST_59 = Symbol("59"); const CONST_60 = Symbol("60"); const CONST_61 = Symbol("61"); const CONST_62 = Symbol("62"); const CONST_63 = Symbol("63"); const CONST_64 = Symbol("64"); const CONST_65 = Symbol("65"); const CONST_66 = Symbol("66"); const CONST_67 = Symbol("67"); const CONST_68 = Symbol("68"); const CONST_69 = Symbol("69"); const CONST_70 = Symbol("70"); const CONST_71 = Symbol("71"); const CONST_72 = Symbol("72"); const CONST_73 = Symbol("73"); const CONST_74 = Symbol("74"); const CONST_75 = Symbol("75"); const CONST_76 = Symbol("76"); const CONST_77 = Symbol("77"); const CONST_78 = Symbol("78"); const CONST_79 = Symbol("79"); const CONST_80 = Symbol("80"); const CONST_81 = Symbol("81"); const CONST_82 = Symbol("82"); const CONST_83 = Symbol("83"); const CONST_84 = Symbol("84"); const CONST_85 = Symbol("85"); const CONST_86 = Symbol("86"); const CONST_87 = Symbol("87"); const CONST_88 = Symbol("88"); const CONST_89 = Symbol("89"); const CONST_90 = Symbol("90"); const CONST_91 = Symbol("91"); const CONST_92 = Symbol("92"); const CONST_93 = Symbol("93"); const CONST_94 = Symbol("94"); const CONST_95 = Symbol("95"); const CONST_96 = Symbol("96"); const CONST_97 = Symbol("97"); const CONST_98 = Symbol("98"); const CONST_99 = Symbol("99"); function funcBySwitch(value){ switch(value) { case CONST_00 : return 0; case CONST_01 : return 1; case CONST_02 : return 2; case CONST_03 : return 3; case CONST_04 : return 4; case CONST_05 : return 5; case CONST_06 : return 6; case CONST_07 : return 7; case CONST_08 : return 8; case CONST_09 : return 9; case CONST_10 : return 10; case CONST_11 : return 11; case CONST_12 : return 12; case CONST_13 : return 13; case CONST_14 : return 14; case CONST_15 : return 15; case CONST_16 : return 16; case CONST_17 : return 17; case CONST_18 : return 18; case CONST_19 : return 19; case CONST_20 : return 20; case CONST_21 : return 21; case CONST_22 : return 22; case CONST_23 : return 23; case CONST_24 : return 24; case CONST_25 : return 25; case CONST_26 : return 26; case CONST_27 : return 27; case CONST_28 : return 28; case CONST_29 : return 29; case CONST_30 : return 30; case CONST_31 : return 31; case CONST_32 : return 32; case CONST_33 : return 33; case CONST_34 : return 34; case CONST_35 : return 35; case CONST_36 : return 36; case CONST_37 : return 37; case CONST_38 : return 38; case CONST_39 : return 39; case CONST_40 : return 40; case CONST_41 : return 41; case CONST_42 : return 42; case CONST_43 : return 43; case CONST_44 : return 44; case CONST_45 : return 45; case CONST_46 : return 46; case CONST_47 : return 47; case CONST_48 : return 48; case CONST_49 : return 49; case CONST_50 : return 50; case CONST_51 : return 51; case CONST_52 : return 52; case CONST_53 : return 53; case CONST_54 : return 54; case CONST_55 : return 55; case CONST_56 : return 56; case CONST_57 : return 57; case CONST_58 : return 58; case CONST_59 : return 59; case CONST_60 : return 60; case CONST_61 : return 61; case CONST_62 : return 62; case CONST_63 : return 63; case CONST_64 : return 64; case CONST_65 : return 65; case CONST_66 : return 66; case CONST_67 : return 67; case CONST_68 : return 68; case CONST_69 : return 69; case CONST_70 : return 70; case CONST_71 : return 71; case CONST_72 : return 72; case CONST_73 : return 73; case CONST_74 : return 74; case CONST_75 : return 75; case CONST_76 : return 76; case CONST_77 : return 77; case CONST_78 : return 78; case CONST_79 : return 79; case CONST_80 : return 80; case CONST_81 : return 81; case CONST_82 : return 82; case CONST_83 : return 83; case CONST_84 : return 84; case CONST_85 : return 85; case CONST_86 : return 86; case CONST_87 : return 87; case CONST_88 : return 88; case CONST_89 : return 89; case CONST_90 : return 90; case CONST_91 : return 91; case CONST_92 : return 92; case CONST_93 : return 93; case CONST_94 : return 94; case CONST_95 : return 95; case CONST_96 : return 96; case CONST_97 : return 97; case CONST_98 : return 98; case CONST_99 : return 99; } } const TABLE = {}; const SYMBOLS = []; for(i=0;i<100;i++) eval('SYMBOLS['+i+'] = CONST_' + ('00'+i).slice(-2)) for(i=0;i<100;i++) TABLE[SYMBOLS[i]] = i; function funcByObject(value){ return TABLE[value]; } function getSymbol(){ return SYMBOLS[Math.floor(Math.random()*100)]; }
Tests:
Switch
for(i=0;i<1000000;i++) funcBySwitch(getSymbol());
Table
for(i=0;i<1000000;i++) funcByObject(getSymbol());