string-timer
Dead simple benchmark/elapsed timer, run purely from string outputs.
installation
npm install string-timer
usage
const StringTimer = import'string-timer'; let time = ; // instantiation begins the timer // do some stuffconsole; // time elapsed: 1.5sec // do some more stuffconsole; // time elapsed: 256ms // set a markerconsole; // time elapsed: 2ms // do some stuffconsole; // time elapsed: 10msconsole; // time elapsed: 5msconsole; // time elapsed: 25ms // calculate from markerconsole; // time elapsed: 40ms
notes
- instantiation initializes a timer
- accessing the timer object itself from a string triggers the calculation and string formatting