diff --git a/ms.js b/ms.js index 88830fa..06bc258 100644 --- a/ms.js +++ b/ms.js @@ -1,5 +1,6 @@ 'use strict'; +const { performance } = require('perf_hooks'); const format = require('./format'); const ms = require('ms'); @@ -8,11 +9,11 @@ const ms = require('ms'); * Returns an `info` with a `ms` property. The `ms` property holds the Value * of the time difference between two calls in milliseconds. */ -module.exports = format(info => { - const curr = +new Date(); +module.exports = format((info) => { + const curr = performance.now(); this.diff = curr - (this.prevTime || curr); this.prevTime = curr; - info.ms = `+${ms(this.diff)}`; + info.ms = `+${ms(Math.round(this.diff))}`; return info; });