Created
July 2, 2016 21:11
-
-
Save deepakshrma/a9076108696860e8546caf7ba9702176 to your computer and use it in GitHub Desktop.
Explaining sync code and slow io operation
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
var alert = console.info; | |
console.time('APP_CALL'); | |
function firstAPI() { | |
alert('first api call'); | |
var i =0; | |
var looptillIndex_sm =1000000; | |
var looptillIndex_lg =1000000000; | |
console.time('API_CALL') | |
//SyncIo | |
while(i < looptillIndex_lg-1){ | |
//while(i < looptillIndex_sm-1){ | |
//one of the worst thing that you can do...Log... | |
if(i%1000000 ==0) console.log("i m here..", i); | |
i++; | |
} | |
console.timeEnd('API_CALL') | |
} | |
function secAPI() { | |
alert('sec api call...'); | |
console.timeEnd('APP_CALL'); | |
} | |
setTimeout(firstAPI, 1000); | |
setTimeout(secAPI, 1002); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment