Last active
April 21, 2018 10:41
-
-
Save tankala/5aafcf204855e5bca53954588c4f0b89 to your computer and use it in GitHub Desktop.
CallBack way to measure execution time in Node.js
This file contains hidden or 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 sleepFunction = function(milliSecondsToSleep) { | |
let startTime = new Date().getTime(); | |
setTimeout(function() { | |
let endTime = new Date().getTime(); | |
console.log("My job done in " + (endTime - startTime) + " ms"); | |
}, milliSecondsToSleep); | |
} | |
let startTime = new Date().getTime(); | |
sleepFunction(1000); | |
sleepFunction(1000); | |
let endTime = new Date().getTime(); | |
console.log("Program took " + (endTime - startTime) + " ms to complete"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment