I've written a C++ program that will take a given process name (eg: notepad.exe) and then when that process has finished, it will return the total CPU time (kernel time + user time) used by that process. this is done using GetProcessTimes() and a call to WaitForSingleObject() to wait for the process to finish.
this seems to work and returns expected results. the only problem is that if i run my program again on the same process it returns different results.
an example of this is i ran notepad, fired up my program to latch onto notepad.exe, wrote some text in notepad and closed it. my program might come back with 15ms cpu time spent.
if i do this same procedure again it comes up with varying results +-3ms.
on larger processes that took several minutes the results varied +-20seconds.
is this to do expected or am i doing something totally wrong? can paste code on request.