Skip to content

Instantly share code, notes, and snippets.

@Unitech
Created February 2, 2015 19:52
Show Gist options
  • Select an option

  • Save Unitech/f3628f02857e0c2976e2 to your computer and use it in GitHub Desktop.

Select an option

Save Unitech/f3628f02857e0c2976e2 to your computer and use it in GitHub Desktop.
var TIME_INTERVAL = 1000;
var oldTime = process.hrtime();
var histogram = probe.histogram({
name : 'Loop delay',
measurement : 'mean',
unit : 'ms'
});
setInterval(function() {
var newTime = process.hrtime();
var delay = (newTime[0] - oldTime[0]) * 1e3 + (newTime[1] - oldTime[1]) / 1e6 - TIME_INTERVAL;
oldTime = newTime;
histogram.update(delay);
}, TIME_INTERVAL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment