Last active
October 23, 2017 13:25
-
-
Save adriennn/20b884856c79ab02b35c6605e92ee733 to your computer and use it in GitHub Desktop.
Timer for nodejs processes
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
/* | |
* 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