Permalink
Browse files

test: fix conversion of microseconds in test

PR-URL: #14706
Fixes: #8728
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
  • Loading branch information...
nickstanish authored and MylesBorins committed Aug 9, 2017
1 parent 28b77d1 commit 9d8464161e513a2b1e4f23ad57de82aedd7bb589
Showing with 3 additions and 3 deletions.
  1. +3 −3 test/pummel/test-process-cpuUsage.js
@@ -17,14 +17,14 @@ while (Date.now() - now < RUN_FOR_MS);
// Get a diff reading from when we started.
const diff = process.cpuUsage(start);
const MICROSECONDS_PER_SECOND = 1000 * 1000;
const MICROSECONDS_PER_MILLISECOND = 1000;
// Diff usages should be >= 0, <= ~RUN_FOR_MS millis.
// Let's be generous with the slop factor, defined above, in case other things
// are happening on this CPU. The <= check may be invalid if the node process
// is making use of multiple CPUs, in which case, just remove it.
assert(diff.user >= 0);
assert(diff.user <= SLOP_FACTOR * RUN_FOR_MS * MICROSECONDS_PER_SECOND);
assert(diff.user <= SLOP_FACTOR * RUN_FOR_MS * MICROSECONDS_PER_MILLISECOND);
assert(diff.system >= 0);
assert(diff.system <= SLOP_FACTOR * RUN_FOR_MS * MICROSECONDS_PER_SECOND);
assert(diff.system <= SLOP_FACTOR * RUN_FOR_MS * MICROSECONDS_PER_MILLISECOND);

0 comments on commit 9d84641

Please sign in to comment.