Skip to content

Instantly share code, notes, and snippets.

@mranney
Created April 13, 2010 19:03
Show Gist options
  • Save mranney/364949 to your computer and use it in GitHub Desktop.
Save mranney/364949 to your computer and use it in GitHub Desktop.
var sys = require('sys');
process.nextTick(function () {
sys.puts("Running from nextTick");
})
setTimeout(function () {
sys.puts("Running from setTimeout 0.");
}, 0);
setTimeout(function () {
sys.puts("Running from setTimeout 1.");
}, 1);
setTimeout(function () {
sys.puts("Running from setTimeout 10.");
}, 10);
setTimeout(function () {
sys.puts("Running from setTimeout 50.");
}, 50);
sys.puts("Running from main.");
@mranney
Copy link
Author

mranney commented Apr 13, 2010

mjr:~$ node timing.js
Running from main.
Running from setTimeout.
Running from nextTick

@mranney
Copy link
Author

mranney commented Apr 13, 2010

mjr:~$ node timing.js
Running from main.
Running from setTimeout 0.
Running from setTimeout 1.
Running from setTimeout 10.
Running from nextTick
Running from setTimeout 50.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment