in reply to Windows 7 CPU usage
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.
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.
That is, why are you measuring cpu usage? And what do you intend to do with the information?
|
|---|