3.14.0 • Published 4 years ago

unitimer v3.14.0

Weekly downloads
157
License
MIT
Repository
github
Last release
4 years ago

unitimer

Universal timer for Node.js and browser:

import createTimer from 'unitimer'

const timer = createTimer().start()
setTimeout(() => {
  const ms = timer.stop() // ms ~= 1000.0
  timer.log() // output to console
}, 1000)

Multiple timers:

import createTimer from 'unitimer'

const [a, b] = createTimer(['a', 'b'])
a.start()
b.start()

// ...

API

timer.start()

Begin measuring interval.

timer.stop()

End the interval. Returns the elapsed time in milliseconds.

Note: start() and stop() can be called multiple times (which affects the total time, count, mean etc.).

timer.took()

Returns the most recent start / stop interval in milliseconds.

timer.mean()

Returns arithmetic average in milliseconds.

timer.total()

Returns the total time taken (an addition of start / stop intervals)

timer.count()

Returns the number of intervals measured.

timer.min()

Returns the minimum interval time recorded.

timer.max()

Returns the maximum interval time recorded.

timer.info(precision)

Returns a string summary of timer total, mean, total, min and max. precision is number of decimal places to show (optional).

timer.log(precision)

console.log of timer.info() (see above)

timer.stats()

Returns a stats object.

3.14.0

4 years ago

3.13.0

5 years ago

3.12.0

5 years ago

3.11.0

6 years ago

3.9.0

6 years ago

3.8.3

6 years ago

3.8.2

6 years ago

3.8.1

6 years ago

3.8.0

6 years ago

3.7.1

7 years ago

3.6.1

7 years ago

3.5.1

7 years ago

3.4.1

7 years ago

3.4.0

7 years ago

3.3.0

7 years ago

3.2.0

7 years ago

3.1.0

8 years ago

3.0.0

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago