Skip to content

Commit bf0bc35

Browse files
rlidwkabnoordhuis
authored andcommitted
doc: better example for process.hrtime()
Fixes #3984.
1 parent b0d04ff commit bf0bc35

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

doc/api/process.markdown

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,15 @@ primary use is for measuring performance between intervals.
417417
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

420-
var t = process.hrtime();
420+
var time = process.hrtime();
421421
// [ 1800216, 927643717 ]
422422

423423
setTimeout(function () {
424-
t = process.hrtime(t);
424+
var diff = process.hrtime(time);
425425
// [ 1, 6962306 ]
426426

427-
console.log('benchmark took %d seconds and %d nanoseconds', t[0], t[1]);
427+
console.log('benchmark took %d seconds and %d nanoseconds',
428+
diff[0], diff[1]);
428429
// benchmark took 1 seconds and 6962306 nanoseconds
429430
}, 1000);
430431

0 commit comments

Comments
 (0)