Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Windows 7 CPU usage

by BrowserUk (Pope)
on Feb 02, 2012 at 13:40 UTC ( #951432=note: print w/ replies, xml ) Need Help??


in reply to Windows 7 CPU usage

  1. Because the author chose to use the 'undocumented' function NtQuerySystemInformation() instead of the documented function GetSystemInfo(), and it has either been withdrawn or changed such that his code no longer works. (Also true on Vista.)
    The NtQuerySystemInformation function and the structures that it returns are internal to the operating system and subject to change from one release of Windows to another. To maintain the compatibility of your application, it is better to use the alternate functions previously mentioned instead.
  2. Because the time being measured is different.

    For example, say the cpu usage over a 1 second period, but measured every 50th of a second, looked like this:

    # #### # ###### ## ######### ## ########### ## ############ ### ############# # ### ############### ## # ### ################# ## # ### # ################## ## # ### # ################### ## # ### # # #################### ## # ### ## # #################### ## # # ### ## ## #################### ## # # ### ## ## #################### ## # # ### ## ## #################### # ## # # ### ## ## #################### # ## # # ### ## ## #################### # ### # ## ### ## ## #################### ## ### #### # ### ## ### #################### ## ### #### # ### ## ### ##################### ### ### #### # ### ############################# ####### ########## 0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0

    Say you measured the whole of that second and got 50% usage; but the system is measuring every half second and when you looked, it had just measured the first half of that second and found it to be 75%. But if you look half a second later, it would show 25%.

    So the average over the whole second, as measured by the system is 75+25/2 = 50%, which is the same 50% you measured, but it all depends upon the exact start and duration of the instrumented period as to what value you'll get.

    As measurements go, cpu usage is a pretty useless measurement of anything, unless you average it out over a longish period -- several seconds. And then it is only useful as a trend indicator, not something you can use for useful statistics or decision making.

  3. It very much depends upon what the "it" is that you are seeking to do?

    That is, why are you measuring cpu usage? And what do you intend to do with the information?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


Comment on Re: Windows 7 CPU usage
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951432]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2014-10-23 20:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (128 votes), past polls