On Dec 7, 2014, at 11:06 PM, // ravi wrote:

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:

setTimeout(function() { console.log(os.cpus()[0].times.idle); }, 2000);

The output I see is:


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!

One thing to consider is if os.cpus() returns CPU usage information from /proc/stats. If so, two things could affect the above (more likely the second):

(1) the first line of /proc/stats in GNU/Linux reports the totals across CPUs.
(2) these numbers seem to be in “jiffies” or 1/100th of a second (USER_HZ).

Time to start digging into the ‘os’ module sources, I guess, though I think Ockham’s Razor continues to point at me.


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 nodejs+unsubscribe@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/3028871E-9DCF-42A5-8013-C6FAD846B2D6%40g8o.net.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 6 | next ›
Discussion Overview
groupnodejs @
postedDec 8, '14 at 4:07a
activeDec 8, '14 at 3:50p

2 users in discussion

// ravi: 5 posts Christopher Rust: 1 post



site design / logo © 2022 Grokbase