Skip to content

Instantly share code, notes, and snippets.

@ray-peters
Created January 7, 2016 22:50
Show Gist options
  • Save ray-peters/a223b8043f785b78f641 to your computer and use it in GitHub Desktop.
Save ray-peters/a223b8043f785b78f641 to your computer and use it in GitHub Desktop.
Testing what throws do to the event loop
var queueJob = function(){
var total = 0;
return function( count ) {
count || ( count = 1 );
for ( var i = 0; i < count; ++i ) {
setTimeout( function(){
++total;
console.log( "job: ", total );
}, 0 );
}
};
}();
queueJob();
setTimeout( function(){
throw "le break";
}, 0 );
queueJob();
var g = function() { return 1; },
f = function() {
var ret = 0,
i = 1;
for ( ; i < 10000000; ++i ) {
ret += g();
}
return ret;
};
f();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment