Last active
August 29, 2015 14:27
-
-
Save camsjams/0d4b63711f297d7233e7 to your computer and use it in GitHub Desktop.
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 startTime; | |
function start() { | |
startTime = new Date().getTime(); | |
} | |
function stop() { | |
var endTime = new Date().getTime(), | |
diff = (endTime - startTime); | |
console.log('\nTime taken: ' + format(diff) + '\n'); | |
} | |
function format(milliseconds) { | |
var hours, minutes, seconds; | |
hours = parseInt(minutes = parseInt(seconds = parseInt(milliseconds / 1000)) / 60) / 60; | |
return (hours % 60) + | |
':' + parseInt(minutes % 60) + | |
':' + parseInt(seconds % 60) + | |
((milliseconds === 0) ? '' : '.' + (milliseconds % 1000)); | |
} | |
module.exports = { | |
start: start, | |
stop: stop | |
}; |
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 profiler = require('./node-profiler-lite'); | |
profiler.start(); | |
//... run code here.. | |
profiler.stop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment