0.1.0 • Published 5 years ago

data-stopwatch v0.1.0

Weekly downloads
6
License
ISC
Repository
github
Last release
5 years ago

data-stopwatch

Measure the elapsed time in your code between two moments

Installation

npm install --save data-stopwatch

Usage

const stopwatch = new Stopwatch();

// Code to measure

// Returns a tuple [number, number] that means [seconds, nanoseconds]
stopwatch.pause().read();
// Returns a single number as milliseconds
stopwatch.pause().readMilliseconds();
// Returns a string representing an approximation of the elapsed time readable to humans
stopwatch.pause().readHumanized();

// Any stopwatch can be paused and resumed as many times as needed
stopwatch.resume();

// Also, it might be useful to mark named moments in the stopwatch

stopwatch.mark( 'name1' );

// Also possible to create marks that only count time after a previous mark
stopwatch.mark( 'name2', 'name1' );

// Their times can be read with the same methods as before but with the mark name as argument
stopwatch.readHumanized( 'name2' );