Skip to content

Instantly share code, notes, and snippets.

@adriennn
Last active October 23, 2017 13:25
Show Gist options
  • Save adriennn/20b884856c79ab02b35c6605e92ee733 to your computer and use it in GitHub Desktop.
Save adriennn/20b884856c79ab02b35c6605e92ee733 to your computer and use it in GitHub Desktop.
Timer for nodejs processes
/*
* Timer to measure timing of stuff in nodejs
*/
class Chrono {
Start() {
this.start = new Date().getTime()
}
Stop() {
return new Date().getTime() - this.start
}
}
// Reset the timer
Chrono.start = 0
// init a new timer
var chrono = new Chrono()
// start the timer before you do something
chrono.Start()
// stop the timer and get the result
var stop = chrono.Stop()
console.log( `It took ${stop} ms to ... the data.`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment