node/test/pummel/test-process-hrtime.js
isaacs 3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00

19 lines
478 B
JavaScript

var common = require('../common');
var assert = require('assert');
var start = process.hrtime();
// process.hrtime() should return an Array
assert(Array.isArray(start));
// busy-loop for 2 seconds
var now = Date.now();
while (Date.now() - now < 2000);
// get a diff reading
var diff = process.hrtime(start);
// should be at least 1 second, at most 2 seconds later
// (the while loop will usually exit a few nanoseconds before 2)
assert(diff[0] >= 1);
assert(diff[0] <= 2);