Co Founder | CEO @ Aglowid IT Solutions
Ronak is the Co-founder and full stack developer of Aglowid IT Solutions, a company that specializes in Full Stack website development for Startups as well as businesses organizations. With the prolonged experience in business management and Web Development, Ronak is intimate with the challenges to work on unique concepts and ideas. Ronak is always in thirst of knowing the latest technologies which helps him consult and provide the best possible solution that his clients requires.
Markdown supported · ⌘↵ to post
Agnius Vasiliauskas
Nice article, I especially liked part about HTTP/2 multiplexing, indeed - every web server should make this requirement a MUST HAVE. However I can't agree on your note that :
I can't believe in this - at a lower level both code structures should be compiled into some sort of goto conditional jumps. Let's check. I've made a JS benchmark. This is switch block:
var rnd = Math.floor(Math.random() * 5); switch(rnd) { case 1: rnd += 1; break; case 2: rnd += 2; break; default: rnd += -1; }and this is if/else block :
var rnd = Math.floor(Math.random() * 5); if (rnd == 1) { rnd += 1; } else if (rnd == 2) { rnd += 2; } else { rnd += -1; }After pasting these blocks into jsbench.me performance comparison suite,- I've got results that switch block is SLOWER by [0% - 2%] on average. Given many unknown factors - how these tests are executed, JS implementation differences between browsers, execution speed measurement errors, biased outcome (maybe after 1000 or more runs performance difference would be 0%) and etc. - it would be rational to neglect these small execution time differences and for practical purposes keep that both should run at the same rate.