hirestime
Version:
thin wrapper around process.hrtime
2 lines (1 loc) • 907 B
JavaScript
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n||self).hirestime=e()}(this,function(){var n=function(n){return 1e3*n[0]+n[1]/1e6},e=function(n){return Number(n.toFixed(2))},r=function(n,r){var t=function(){return e(r())};return t.startedAt=function(){return n},t.seconds=t.s=function(){return e(r()/1e3)},t.milliseconds=t.ms=function(){return e(r())},t.microseconds=t.us=function(){return e(1e3*r())},t.nanoseconds=t.ns=function(){return e(1e6*r())},t};return"undefined"!=typeof process&&process.hrtime?function(){var e=process.hrtime();return r(n(e),function(){return n(process.hrtime(e))})}:"undefined"!=typeof window&&window.performance?function(){var n=window.performance.now();return r(n,function(){return window.performance.now()-n})}:function(){var n=Date.now();return r(n,function(){return Date.now()-n})}});