Hello all,
I posted this question on node-forward/help on Gitter, so apologies if you are
seeing this again.
I am stumped by what must clearly be a misreading on my part. Node 0.10 docs
say that each element of os.cpus() contains information about each CPU/core.
This information includes "the number of milliseconds the CPU/core spent in:
user, nice, sys, idle, and irq” (the docs do not say milliseconds of what, but
I assume it means milliseconds since the system was last started). Note that
this used to be, in v0.8 (and I assume before), reported in CPU ticks, but
seems to have switched to milliseconds for v0.10.
Now for the puzzle: say I do this:
console.log(os.cpus()[0].times.idle);
setTimeout(function() { console.log(os.cpus()[0].times.idle); }, 2000);
The output I see is:
39035126800
39035144500
Assuming that ordering of CPUs/cores is consistent in the array returned by
os.cpus(), it’s not clear how to square the above with the docs. The difference
between the times reported is 17700ms i.e., CPU 0 was idle for 17 seconds in
the 2 seconds between the two calls!
I guess I am doing something trivially wrong in the above, but what is it?
Any help appreciated!
—ravi
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/CAEEC821-242A-4C65-8F07-C6B751A1B07E%40g8o.net.
For more options, visit https://groups.google.com/d/optout.