1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 10:19:30 +02:00
OpenSTF/lib/util/timeutil.js
2019-06-12 10:29:07 +02:00

22 lines
556 B
JavaScript

/**
* Copyright © 2019 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
const timeutil = Object.create(null)
timeutil.now = function(unit) {
const hrTime = process.hrtime()
switch (unit) {
case 'milli':
return hrTime[0] * 1000 + hrTime[1] / 1000000
case 'micro':
return hrTime[0] * 1000000 + hrTime[1] / 1000
case 'nano':
return hrTime[0] * 1000000000 + hrTime[1]
default:
return hrTime[0] * 1000000000 + hrTime[1]
}
}
module.exports = timeutil