data-stopwatch
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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' );

Package Sidebar

Install

npm i data-stopwatch

Weekly Downloads

2

Version

0.1.0

License

ISC

Unpacked Size

12.9 kB

Total Files

7

Last publish

Collaborators

  • pedromsilva