-
-
Save indutny/add4bfa2a915eab3b108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof print === 'undefined') print = function(str) { console.log(str); }; | |
function bench() { | |
function big_switch(x) { | |
switch ('__' + x + '__') { | |
default: return 0; | |
case "__1__": return 1; | |
case "__2__": return 2; | |
case "__3__": return 3; | |
case "__4__": return 4; | |
case "__5__": return 5; | |
case "__6__": return 6; | |
case "__7__": return 7; | |
case "__8__": return 8; | |
case "__9__": return 9; | |
case "__10__": return 10; | |
case "__11__": return 11; | |
case "__12__": return 12; | |
case "__13__": return 13; | |
case "__14__": return 14; | |
case "__15__": return 15; | |
case "__16__": return 16; | |
case "__17__": return 17; | |
case "__18__": return 18; | |
case "__19__": return 19; | |
case "__20__": return 20; | |
} | |
} | |
function show(offset) { | |
print('starting the show'); | |
var start = +new Date; | |
for (var i = 1; i <= count; i++) { | |
for (var k = 0; k < different; k++) { | |
big_switch(k + offset); | |
} | |
} | |
var end = +new Date; | |
print('show ended: ' + (end - start) + 'ms'); | |
} | |
var different = 8, | |
count = (40000000 / different) | 0; | |
show(1); | |
show(10); | |
show(3); | |
show(9); | |
for (var k = 1; k <= 20; k++) { | |
print(big_switch(k)); | |
} | |
} | |
bench(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment