Browse files

Update the docs with an hrtime() diff example.

  • Loading branch information...
1 parent 564d38c commit 235f6a3c2fc8e1a556f2778b0e50da4ea531510c @TooTallNate committed Mar 6, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 doc/api/process.markdown
View
14 doc/api/process.markdown
@@ -368,6 +368,16 @@ tuple Array. It is relative to an arbitrary time in the past. It is not
related to the time of day and therefore not subject to clock drift. The
primary use is for measuring performance between intervals.
-Example output looks like:
+You may pass in the result of a previous call to `process.hrtime()` to get
+a diff reading, useful for benchmarks and measuring intervals:
- [ 1800216, 927643717 ]
+ var t = process.hrtime();
+ // [ 1800216, 927643717 ]
+
+ setTimeout(function () {
+ t = process.hrtime(t);
+ // [ 1, 6962306 ]
+
+ console.log('benchmark took %d seconds and %d nanoseconds', t[0], t[1]);
+ // benchmark took 1 seconds and 6962306 nanoseconds
+ }, 1000);

0 comments on commit 235f6a3

Please sign in to comment.