1.0.3 • Published 5 years ago

performance-measure v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

performance-measure

Build Status

measure specilizing in speed up contests.

Install

npm install performance-measure

Example

codes:

const PerformanceMeasure = require('performance-measure')

async function main() {
  const m = new PerformanceMeasure()
  m.start('A')
  await sleep(100)
  m.end('A')

  m.start('A')
  await sleep(200)
  m.end('A')

  m.start('B')
  await sleep(100)
  m.end('B')
 
  m.start('C')
  await sleep(400)
  m.endAs('C', 'foobar')

  console.log(m.print())
}

main ()

function sleep(ms = 0) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

result:

name    size  sum     max     min     mean  
------  ----  ------  ------  ------  ------
foobar     1  404.43  404.43  404.43  404.43
A          2  308.94  204.18  104.76  154.47
B          1  100.44  100.44  100.44  100.44

SEE ALSO: examples/*.js

License

MIT