Skip to content

Instantly share code, notes, and snippets.

@sapher
Created December 30, 2013 15:51
Show Gist options
  • Save sapher/8183715 to your computer and use it in GitHub Desktop.
Save sapher/8183715 to your computer and use it in GitHub Desktop.
Simply convert the "high-resolution real time" (difference) provided by NodeJS to an understandable value.
exports.convertHrTimeToMs = (hrtime) =>
diff = process.hrtime(hrtime)
return parseInt((diff[0] * 1e9 + diff[1]) * 1e-6)
convertHrTimeToMs = require("./convertHrTimeToMs.coffee").convertHrTimeToMs
time = process.hrtime()
setTimeout () =>
console.log convertHrTimeToMs time
#output 1253 (ms) for example
, 1250 #ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment