GT2/GT2-iOS/node_modules/minipass/bench/lib/timer.js

16 lines
387 B
JavaScript
Raw Normal View History

2018-02-12 17:26:06 +00:00
'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)
}
}
}