Skip to content

Commit 872cb0d

Browse files
jhnnsbnoordhuis
authored andcommitted
doc: improve example of process.hrtime()
The example clarifies now that diff[0] * 1000000000 + diff[1] equals the result in nanoseconds.
1 parent 50e88d0 commit 872cb0d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

doc/api/process.markdown

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,14 @@ You may pass in the result of a previous call to `process.hrtime()` to get
418418
a diff reading, useful for benchmarks and measuring intervals:
419419

420420
var time = process.hrtime();
421-
// [ 1800216, 927643717 ]
421+
// [ 1800216, 25 ]
422422

423423
setTimeout(function () {
424424
var diff = process.hrtime(time);
425-
// [ 1, 6962306 ]
425+
// [ 1, 552 ]
426426

427-
console.log('benchmark took %d seconds and %d nanoseconds',
428-
diff[0], diff[1]);
429-
// benchmark took 1 seconds and 6962306 nanoseconds
427+
console.log('benchmark took %d nanoseconds', diff[0] * 1e9 + diff[1]);
428+
// benchmark took 1000000527 nanoseconds
430429
}, 1000);
431430

432431
[EventEmitter]: events.html#events_class_events_eventemitter

0 commit comments

Comments
 (0)