On Dec 8, 2014, at 12:43 AM, Christopher Rust wrote:

I can't comment on how cpu idle time is calculated or if the cpus() array is consistently ordered but I can point out that setTimeout is not expected to be perfectly accurate.

Still, 17 seconds seems like a lot. Are you saying that's 17 seconds real time as well?

It’s not 17 seconds in real time… it’s two seconds :-). Hence my puzzlement. We can add some detail to bring this out:

         console.log("Time is", Date.now(),
                     "and idle time is", os.cpus()[0].times.idle);

And the output is:

Time is 1418051000768 and idle time is 39311772900
Time is 1418051002770 and idle time is 39311790100
Time is 1418051004772 and idle time is 39311808000
Time is 1418051006774 and idle time is 39311824600

The between intervals is fairly consistent and about 2000ms as expected. The idle times for the corresponding intervals are approx 17s, 18s, 16.5s! (if laziness is a virtue of a programmer, I think I might have stumbled upon the Holy Grail: the ability to squeeze more idle time than are available on the clock!).

Closer inspection reveals what might be the issue: if you take the idle time reported to be not in ms, but 100*ms (where 100 = GNU/Linux clock ticks per sec), then it starts to seem right. Throwing away the *100, the idle times become:


Or approx 2s, 1s, 2s each.

What does continue to puzzle me is that if the ‘os’ module is adding on a extra *100 to the time, then how is it reporting data at this level of granularity i.e., there should be a lot more trailing zeroes, since the OS does not report this data at ms granularity.


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/3C909E04-D714-42B5-B66D-05EA5E878EE8%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 | 5 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