Skip to content

Instantly share code, notes, and snippets.

@camsjams
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camsjams/0d4b63711f297d7233e7 to your computer and use it in GitHub Desktop.
Save camsjams/0d4b63711f297d7233e7 to your computer and use it in GitHub Desktop.
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
};
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