node-pid-controller icon indicating copy to clipboard operation
node-pid-controller copied to clipboard

High resolution timer

Open jimbuck opened this issue 10 years ago • 1 comments

Node provides access to high resolution time through process.hrtime(). It can also be used to calculate the time difference between calls.

Example (from NodeJS Docs):

var time = process.hrtime();
// [ 1800216, 25 ]

setTimeout(function() {
  var diff = process.hrtime(time);
  // [ 1, 552 ]

  console.log('benchmark took %d nanoseconds', diff[0] * 1e9 + diff[1]);
  // benchmark took 1000000527 nanoseconds
}, 1000);

Do you see a benefit for the higher precision? I see that dt is stored as seconds, so wasn't sure if higher precision would actually make a difference.

jimbuck avatar Dec 22 '15 20:12 jimbuck

I guess that wouldn't hurt.

Philmod avatar Dec 24 '15 05:12 Philmod