This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

doc: better example for process.hrtime()

Fixes #3984.
  • Loading branch information...
rlidwka authored and bnoordhuis committed Oct 3, 2012
1 parent b0d04ff commit bf0bc3565b21d857afc53a2d9c2fd773d973cdf5
Showing with 4 additions and 3 deletions.
  1. +4 −3 doc/api/process.markdown
View
@@ -417,14 +417,15 @@ primary use is for measuring performance between intervals.
You may pass in the result of a previous call to `process.hrtime()` to get
a diff reading, useful for benchmarks and measuring intervals:
var t = process.hrtime();
var time = process.hrtime();
// [ 1800216, 927643717 ]
setTimeout(function () {
t = process.hrtime(t);
var diff = process.hrtime(time);
// [ 1, 6962306 ]
console.log('benchmark took %d seconds and %d nanoseconds', t[0], t[1]);
console.log('benchmark took %d seconds and %d nanoseconds',
diff[0], diff[1]);
// benchmark took 1 seconds and 6962306 nanoseconds
}, 1000);

0 comments on commit bf0bc35

Please sign in to comment.