Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High resolution timer #6

Open
jimbuck opened this issue Dec 22, 2015 · 1 comment
Open

High resolution timer #6

jimbuck opened this issue Dec 22, 2015 · 1 comment

Comments

@jimbuck
Copy link

jimbuck commented Dec 22, 2015

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.

@Philmod
Copy link
Owner

Philmod commented Dec 24, 2015

I guess that wouldn't hurt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants