Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm calling
GetProcessTimes()
periodically in a loop which does the very same thing on each iteration, but it seems to generate the same results every time and only changes time to time. Is it a normal behaviour ? Shouldn't the results change a little bit over time ?
void ImCalledPeriodically() {
static const DWORD dwPid = ::GetCurrentProcessId();
static const HANDLE hProc = ::OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, dwPid );
static FILETIME ftUnused1, ftUnused2; // Unused, mandatory parameters.
ULARGE_INTEGER uliUsr, uliKrn;
::GetProcessTimes( hProc, & ftUnused1, & ftUnused2, (_FILETIME *)& uliKrn, (_FILETIME *)& uliUsr);
printf("usr=%I64d krn=%I64d", uliUsr.QuadPart, uliKrn.QuadPart );
// etc...
The output values only change time to times, for example :
641002,
641002,
641002,
641002
1092007,
1092007,
1092007,
1092007
etc...
Shouldn't it change a few every time ? Is there some kind of refresh rate internal to the function ?
Thanks for your help.
–
–
–
You are probably noticing that the values are only changing about every 16 ms, which is the default time interval that Windows uses for its timers and the thread time quantum. So, if you are making the calls in a relatively tight loop, you will get repeating values.
On top of this is the fact that the times show actual CPU consumption. If your process does little or no work in between calls, the times will not increase.
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.