summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/tar/node_modules/minipass/bench/lib/timer.js
blob: 8d8fe3d80d99078dac45ee8053c57e7efa3550d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'use strict'
module.exports = _ => {
  const start = process.hrtime()
  return _ => {
    const end = process.hrtime(start)
    const ms = Math.round(end[0]*1e6 + end[1]/1e3)/1e3
    if (!process.env.isTTY)
      console.log(ms)
    else {
      const s = Math.round(end[0]*10 + end[1]/1e8)/10
      const ss = s <= 1 ? '' : ' (' + s + 's)'
      console.log('%d%s', ms, ss)
    }
  }
}