2.0.6 • Published 2 years ago

@watchmen/tymer v2.0.6

Weekly downloads
16
License
ISC
Repository
-
Last release
2 years ago

tymer

time stuff

XO code style styled with prettier Build Status npm (scoped)

usage

import

import Timer from 'tymer'

stop

// timer is automatically started on construction
//
const timer = new Timer('some-event')

// some event occurs here

timer.stop()

explicit start

const timer = new Timer('some-event')

const array = [1, 2, 3]
for (let i = 0; i < array.length; i++) {
  timer.start()
  // do stuff
  timer.stop()
}

lap

const timer = new Timer('some-event')

// some event occurs here

timer.lap() // lap() stops and then immediately starts

// other event here

timer.stop()

async

const parentTimer = new Timer('some-event')

something().then(()=>{
  const childTimer = new Timer()
  // some event
  childTimer.stop()
  // need child timer to track time spent in async segment
  parentTimer.record(childTimer.last())
})

report

console.log('timer: report=%o', timer.toString())
some-event: count=1, min=0.014, max=0.048, max2=0.031, last=0.015, avg=0.026, avg2=0.021, total=0.000s

max2 is the second max, and avg2 is the average without the max.

this is to provide insight into loops where the first call incurs an initialization cost.

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.6

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.4

6 years ago

1.2.3

7 years ago