troubleshooting Question

CPU time taken to run a process.

Avatar of markserv
markserv asked on
CMicrosoft DevelopmentEditors IDEs
10 Comments3 Solutions1474 ViewsLast Modified:
Hey all.

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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros